Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
RegConnectRegistry (advapi32)
.
C# Signature:
[DllImport("advapi32.dll", SetLastError = true)]
static extern int RegConnectRegistry(string lpmachineName, int hKey, ref int phKResult);
[DllImport("advapi32.dll", SetLastError=true)]
static extern TODO RegConnectRegistry(TODO);
e.g.:
[DllImport("advapi32.dll", SetLastError = true)]
static extern long RegConnectRegistry(string lpmachineName, long hKey, out long phKResult);
VB Signature:
Declare Auto Function RegConnectRegistry Lib "Advapi32" ( _
ByVal lpMachineName As String, _
ByVal hKey As IntPtr, _
ByRef phkResult As IntPtr _
) As Integer
User-Defined Types:
None.
Alternative Managed API:
Windows.Win32.RegistryKey.OpenRemoteBaseKey
VB Signature:
Declare Auto Function RegConnectRegistry Lib "Advapi32" ( _
ByVal lpMachineName As String, _
ByVal hKey As IntPtr, _
ByRef phkResult As IntPtr _
) As Integer
User-Defined Types:
None.
Notes:
LONG RegConnectRegistry(
LPCTSTR lpMachineName,
HKEY hKey,
PHKEY phkResult
);
Alternative Managed API:
Windows.Win32.RegistryKey.OpenRemoteBaseKey
Tips & Tricks:
Please add some!
Notes:
LONG RegConnectRegistry(
LPCTSTR lpMachineName,
HKEY hKey,
PHKEY phkResult
);
VB Sample Code:
' static method
Public Shared Function OpenRemoteBaseKey(ByVal Hive As RegistryHive, ByVal RemotePC As String) As RegistryKey
Dim ret As Integer
Dim hRemoteKey As IntPtr
Tips & Tricks:
Please add some!
ret = RegConnectRegistry("\\" & RemotePC, New IntPtr(Hive), hRemoteKey)
If ret <> 0 Then
Throw New Win32Exception(ret)
End If
Sample Code:
' static method
Public Shared Function OpenRemoteBaseKey(ByVal Hive As RegistryHive, ByVal RemotePC As String) As RegistryKey
Dim ret As Integer
Dim hRemoteKey As IntPtr
Dim ans As New RegistryKey
ans.IsRootHive = False
ans.hKey = hRemoteKey
Return ans
End Function
ret = RegConnectRegistry("\\" & RemotePC, New IntPtr(Hive), hRemoteKey)
If ret <> 0 Then
Throw New Win32Exception(ret)
End If
C# Sample Code:
private con;
Dim ans As New RegistryKey
ans.IsRootHive = False
ans.hKey = hRemoteKey
Return ans
End Function
public RemoteRegistryReader(string computerName)
{
int iHKEY, iResult, iReturn;
bool bOK = false;
string sValue = string.Empty;
if (iReturn == 0)
{
bOK = true;
iReturn = iResult;
}
else
{
bOK = false;
}
return iReturn;
}
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).