Results 1 to 2 of 2

Thread: RegQueryInfoKey api call

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Bournemouth, England
    Posts
    2

    Unhappy

    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

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Bournemouth, England
    Posts
    2

    Smile

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width