Platform SDK: Registry |
The RegConnectRegistry function establishes a connection to a predefined registry handle on another computer.
LONG RegConnectRegistry( LPCTSTR lpMachineName, // computer name HKEY hKey, // predefined registry handle PHKEY phkResult // buffer for remote key handle );
\\computername
If lpMachineName is NULL, the local computer name is used.
HKEY_LOCAL_MACHINE
HKEY_USERS
Windows NT/2000: HKEY_PERFORMANCE_DATA, if the remote computer is running Windows NT/Windows 2000
Windows 95/98: HKEY_DYN_DATA, if the remote computer is running Windows 95 or Windows 98.HKEY_CURRENT_CONFIG, if the remote computer is running Windows 95 or Windows 98.
You cannot specify the HKEY_CLASSES_ROOT or HKEY_CURRENT_USER value for this parameter.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
When a handle returned by RegConnectRegistry is no longer needed, it should be closed by calling RegCloseKey.
Windows 95/98: No registry subkey or value name may exceed 255 characters.
Windows 95: To use RegConnectRegistry on Windows 95, you must install the Microsoft Remote Registry service. If you don't do this, calls to RegConnectRegistry return ERROR_DLL_INIT_FAILED. Perform the following steps to install the Microsoft Remote Registry service.
To install the Microsoft Remote Registry service
If you are prompted to specify the location of additional files, specify the path to the Windows 95 source files on a shared network directory or on the Windows 95 compact disc.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winreg.h; include Windows.h.
Library: Use Advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.