RegEnumKey

  • Thread starter Thread starter Jonathan Randal via .NET 247
  • Start date Start date
J

Jonathan Randal via .NET 247

<System.Runtime.InteropServices.DllImport("advapi32.dll", EntryPoint:="RegEnumKeyA", _
SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Function RegEnumKey(ByVal hKey As Long, _
ByVal dwIndex As Long, ByVal lpName As String, _
ByVal cbName As Long) As Long

End Function

When I call the above function I get the following values:
RegEnumKey returns this Value: 1115485332704329987
LastErrorCode function returns this: 126

Why is this happing?

Def:
126 The specified module could not be found. ERROR_MOD_NOT_FOUND
 
Why is this happing?

Because your declaration is incorrect. You're passing Long (64-bit)
where Integer (32-bit) is expected, and you're passing Unicode strings
to an ANSI function. See if you can find a correct declaration at
http://www.pinvoke.net or better yet use the RegistryKey class.



Mattias
 
Back
Top