Using RegConnectRegistry() with VB.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Patrick

    #1

    Using RegConnectRegistry() with VB.net

    I cannot seem to get the following code to work in VB.net:

    ----------------------------------------------------------------------------
    -------------------------
    Const HKEY_LOCAL_MACH INE = &H80000002

    Declare Function RegConnectRegis try Lib "advapi32.d ll" Alias
    "RegConnectRegi stryA" _
    (ByVal lpMachineName As String, ByVal hKey As Int32, ByVal phkResult As
    Int32) As Int32

    (the code below would be placed in a sub or function)
    Dim lReturnCode as Int32
    Dim lhRemoteRegistr y as Int32

    lReturnCode = RegConnectRegis try("\\MyMachin e", HKEY_LOCAL_MACH INE,
    lhRemoteRegistr y)

    ----------------------------------------------------------------------------
    -------------------------

    lReturnCode always returns 1780, when it should be returning zero. If I
    take this same code and copy it into a VB 6 project (changing the Int32's to
    Long's of course) it works perfectly and connects to the remote registry.

    Any ideas?

    Thanks,
    Brian



Working...