LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Excel coredumps with each call to a dll - for function RegQueryValueExA in advapi32.dll

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CALL .NET FUNCTION FROM EXCEL VSTO Beginner Excel Worksheet Functions 0 February 27th 08 06:57 AM
Hashing function CryptAcquireContext Lib "advapi32" not working in new computer. Stephen Rasey[_3_] Excel Programming 5 December 25th 06 04:05 AM
How can I call a JavaScript Function from Excel VBA [email protected] Excel Programming 0 April 17th 06 03:33 PM
call a excel function from a vb project Alex281 Excel Programming 2 March 29th 06 05:22 AM
Help with VB Call function from Excel Lawrence M. Seldin, CMC, CPC Excel Programming 0 June 3rd 05 06:13 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"