Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using a call to the following function
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _ "RegQueryValueExA" (ByVal hKey As Long, _ ByVal lpValueName As String, _ ByVal lpReserved As Long, _ lpType As Long, _ lpData As Any, _ lpcbData As Long) As Long I then use this in code as follows, and each time I run it excel just dies horribly. Is there something I am doing wrong? has anyone got any working examples of RegQueryValueEx ? I have checked the dll file exists and has this function call Thanks Tom ' Hello, World! for the Registry: gets this machine's name and prints ' it out. Public Sub tempreg() Dim pszName As String Dim nNameLen As Long: nNameLen = 255 Dim hkResult As Long, hStartKey As Long Dim nResult As Long Dim nResult2 hStartKey = HKEY_LOCAL_MACHINE nResult = ERROR_SUCCESS nResult = RegOpenKeyEx(hStartKey, _ "SYSTEM\\CurrentControlSet\\Control\\ComputerN ame\ \ActiveComputerName", _ 0&, KEY_READ, hkResult) If (ERROR_SUCCESS = nResult) Then nResult = RegQueryValueEx(hkResult, "ComputerName", 0, 0, pszName, nNameLen) If (ERROR_SUCCESS = nResult) Then MsgBox "Hello, world, from " & pszName Else MsgBox "I don't even know my own name." End If End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CALL .NET FUNCTION FROM EXCEL | Excel Worksheet Functions | |||
Hashing function CryptAcquireContext Lib "advapi32" not working in new computer. | Excel Programming | |||
How can I call a JavaScript Function from Excel VBA | Excel Programming | |||
call a excel function from a vb project | Excel Programming | |||
Help with VB Call function from Excel | Excel Programming |