PDA

Click to See Complete Forum and Search --> : RegQueryInfoKey api call


NeilB
Jun 3rd, 2000, 10:55 PM
I wrote a program at home on my Win98 PC using the RegQueryInfoKey api call which worked fine but I try to run it on my NT pc at work and it comes up with error 87 ('invalid parameter'). I then wrote a simple program at work (see below) with just one label and one command button just to test the function but it comes up with the error as well. I used the usual function declarations and constants copied and pasted from the VB API text viewer. The description of the api call from the MSDN site tells me that if the call works from 9.x but not from NT\2000 then there is a problem with the class name string and/or it's associated buffer. I have tried setting up variables for both and have tried setting both to null (0&) to no effect. I have also tried different values for the class buffer (lpcClass) but that didn't help either. I am pulling my hair out as to what it could be. HELP!!!!

Thanks in advance,
NeilB

Here is my code:

Private Sub Command1_Click()
Dim query_result As Long
Dim NumSubKeys As Long
Dim lpClass As String
Dim lpcClass As Long
Dim MaxKeyLen As Long
Dim MaxClassLen As Long
Dim NumValues As Long
Dim MaxNameLen As Long
Dim MaxValueLen As Long
Dim SecDes As Long 'not used:I used KEY_READ instead
Dim LastWrite As FILETIME
Dim root As Long
root = &H80000002

lpcClass = 255
lpClass = Space$(lpcClass)

query_result = RegQueryInfoKey(root, lpClass, lpcClass, 0&, NumSubKeys, MaxKeyLen, MaxClassLen, NumValues, MaxNameLen, MaxValueLen, KEY_READ, LastWrite)
If query_result <> ERROR_SUCCESS Then
MsgBox "Sorry, couldn't get query with error code " + Format$(query_result), 64, "Error"
Else
Label1.Caption = "Number of subkeys = " + NumSubKeys
End If
End Sub

NeilB
Jun 7th, 2000, 02:29 AM
I managed to work it out myself in the end: the reserved argument is meant to be null, 0&, but it has to be PASSED BY VALUE !!!!

It's the same for other registry functions so watch out for it.



Neil B