RegEnumKey

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Randal via .NET 247

    #1

    RegEnumKey

    <System.Runtime .InteropService s.DllImport("ad vapi32.dll", EntryPoint:="Re gEnumKeyA", _
    SetLastError:=T rue, CharSet:=CharSe t.Unicode, ExactSpelling:= True, _
    CallingConventi on:=CallingConv ention.StdCall) > _
    Private Shared Function RegEnumKey(ByVa l 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: 111548533270432 9987
    LastErrorCode function returns this: 126

    Why is this happing?

    Def:
    126 The specified module could not be found. ERROR_MOD_NOT_F OUND


    --------------------------------
    From: Jonathan Randal

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>6kw000uCCkW HJXBYZUacyA==</Id>
  • Mattias Sjögren

    #2
    Re: RegEnumKey

    >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

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...