ILocalRegistry4.GetLocalRegistryRootEx(UInt32, UInt32, String) Method

Definition

Returns the local registry root.

public:
 int GetLocalRegistryRootEx(System::UInt32 dwRegType, [Runtime::InteropServices::Out] System::UInt32 % pdwRegRootHandle, [Runtime::InteropServices::Out] System::String ^ % pbstrRoot);
int GetLocalRegistryRootEx(unsigned int dwRegType, [Runtime::InteropServices::Out] unsigned int & pdwRegRootHandle, [Runtime::InteropServices::Out] std::wstring const & & pbstrRoot);
public int GetLocalRegistryRootEx (uint dwRegType, out uint pdwRegRootHandle, out string pbstrRoot);
abstract member GetLocalRegistryRootEx : uint32 * uint32 * string -> int
Public Function GetLocalRegistryRootEx (dwRegType As UInteger, ByRef pdwRegRootHandle As UInteger, ByRef pbstrRoot As String) As Integer

Parameters

dwRegType
UInt32

[in] A __VsLocalRegistryType value that specifies the registry hive.

pdwRegRootHandle
UInt32

[in] A __VsLocalRegistryRootHandle value that specifies the registry root handle.

pbstrRoot
String

[out] Pointer to a string that contains the local registry root.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Examples

ILocalRegistry4* pLocalRegistry = /* Get the local registry */  
VSLOCALREGISTRYROOTHANDLE hKey = RegHandle_Invalid;  
BSTR bstrPath = NULL;  
if( SUCCEEDED( pLocalRegistry->GetRegistryRootEx(  
    RegType_UserSettings, &hKey, &bstrPath ) ) )  
{  
    HKEY hkUser = NULL;  
    LONG lr = RegOpenKeyEx( hKey, bstrPath, 0, KEY_READ, &hkUser );  
    if( ERROR_SUCCESS == lr )  
    {  
        // Query values as needed  
        RegCloseKey( hkUser );  
    }  
    SysFreeString(bstrPath);  
}  

Remarks

GetLocalRegistryRootEx should be used for all new code that requires access to the registry root. The method allows for placing the per-computer configuration pieces of the registry under a different registry key and/or path.

The corresponding service is SID_SLocalRegistry

This interface is thread-safe and can be called from a background thread directly or by using a marshaled pointer.

Applies to