T
Tom Med
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\\ComputerName\
\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
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\\ComputerName\
\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