ILocalRegistry4::GetLocalRegistryRootEx Method (UInt32, UInt32, String^)

 

Returns the local registry root.

Namespace:   Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop.9.0 (in Microsoft.VisualStudio.Shell.Interop.9.0.dll)

int GetLocalRegistryRootEx(
	unsigned int dwRegType,
	[OutAttribute] unsigned int% pdwRegRootHandle,
	[OutAttribute] String^% pbstrRoot
)

Parameters

dwRegType
Type: System::UInt32

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

pdwRegRootHandle
Type: System::UInt32

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

pbstrRoot
Type: System::String^

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

Return Value

Type: System::Int32

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

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.

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);
}
Return to top
Show: