RegEnumKey

  • Thread starter Jonathan Randal via .NET 247
  • 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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top