Click to See Complete Forum and Search --> : RegEnumKeyEx Error 87


Clearcode
April 27th, 2001, 10:08 AM
I keep getting the error "87 Parameter is incorrect" when calling the RegEnumKeyEx API call.

My declaration is:

private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (byval hKey as Long, byval dwIndex as Long, byval lpName as string, lpcbName as Long, lpReserved as Long, byval lpClass as string, lpcbClass as Long, lpftLastWriteTime as Long) as Long




and the use is:

'\\ Initialise the string that are going to hold the values...
lKeyLen = 2000
lClassLen = 2000
sKeyName = string$(lKeyLen, 0)
sClassName = string$(lClassLen, 0)

'\\ Enumerate through the keys adding each one...
While lRet = 0
lRet = RegEnumKeyEx(Key, lIndex, sKeyName, lKeyLen, lReserved, sClassName, lClassLen, lpftLastWriteTime)
lIndex = lIndex + 1
Wend




Any ideas?
TIA,
Duncan
I have checked that Key is a valid open key

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

John G Duffy
April 27th, 2001, 04:51 PM
Your Last parameter on the declaration is wrong. here is the correct declaration


public Type FILETIME
dwLowDateTime as Long
dwHighDateTime as Long
End Type

Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" _
(byval hKey as Long, byval dwIndex as Long, _
byval lpname as string, lpcbName as Long, _
byval lpReserved as Long, _
byval lpClass as string, _
lpcbClass as Long, _
lpftLastWriteTime as FILETIME) as Long





John G

Clearcode
April 30th, 2001, 02:50 AM
Full marks - That was precisely it.

Thanks,
D.

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com