Skip to content

Latest commit

 

History

History
133 lines (88 loc) · 5.46 KB

nf-winreg-regconnectregistryw.md

File metadata and controls

133 lines (88 loc) · 5.46 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winreg.RegConnectRegistryW
RegConnectRegistryW function (winreg.h)
Establishes a connection to a predefined registry key on another computer. (Unicode)
RegConnectRegistry
RegConnectRegistry function
RegConnectRegistryW
_win32_regconnectregistry
base.regconnectregistry
winreg/RegConnectRegistry
winreg/RegConnectRegistryW
base\regconnectregistry.htm
winprog
d7fb41cc-4855-4ad7-879c-b1ac85ac5803
12/05/2018
RegConnectRegistry, RegConnectRegistry function, RegConnectRegistryA, RegConnectRegistryW, _win32_regconnectregistry, base.regconnectregistry, winreg/RegConnectRegistry, winreg/RegConnectRegistryA, winreg/RegConnectRegistryW
winreg.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
RegConnectRegistryW (Unicode) and RegConnectRegistryA (ANSI)
Advapi32.lib
Advapi32.dll
Windows
19H1
RegConnectRegistryW
winreg/RegConnectRegistryW
c++
APIRef
kbSyntax
DllExport
Advapi32.dll
API-MS-Win-Core-Registry-l2-1-0.dll
advapi32legacy.dll
API-MS-Win-Core-Registry-l2-2-0.dll
RegConnectRegistry
RegConnectRegistryA
RegConnectRegistryW

RegConnectRegistryW function

-description

Establishes a connection to a predefined registry key on another computer.

-parameters

-param lpMachineName [in, optional]

The name of the remote computer. The string has the following form:

\\computername

The caller must have access to the remote computer or the function fails.

If this parameter is NULL, the local computer name is used.

-param hKey [in]

A predefined registry handle. This parameter can be one of the following predefined keys on the remote computer.

HKEY_LOCAL_MACHINE HKEY_PERFORMANCE_DATA HKEY_USERS

-param phkResult [out]

A pointer to a variable that receives a key handle identifying the predefined handle on the remote computer.

-returns

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.

-remarks

RegConnectRegistry requires the Remote Registry service to be running on the remote computer. By default, this service is configured to be started manually. To configure the Remote Registry service to start automatically, run Services.msc and change the Startup Type of the service to Automatic.

Windows Server 2003 and Windows XP/2000:  The Remote Registry service is configured to start automatically by default.

When a handle returned by RegConnectRegistry is no longer needed, it should be closed by calling RegCloseKey.

If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate as Guest" policy is enabled, the function fails. Note that this policy is enabled by default if the computer is joined to a workgroup.

If the current user does not have proper access to the remote computer, the call to RegConnectRegistry fails. To connect to a remote registry, call LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and ImpersonateLoggedOnUser before calling RegConnectRegistry.

Windows 2000:  One possible workaround is to establish a session to an administrative share such as IPC$ using a different set of credentials. To specify credentials other than those of the current user, use the WNetAddConnection2 function to connect to the share. When you have finished accessing the registry, cancel the connection.

Windows XP Home Edition:  You cannot use this function to connect to a remote computer running Windows XP Home Edition. This function does work with the name of the local computer even if it is running Windows XP Home Edition because this bypasses the authentication layer.

Note

The winreg.h header defines RegConnectRegistry as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

RegCloseKey

Registry Functions

Registry Overview