Share via


ILocalRegistry4.GetLocalRegistryRootEx Method

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)

Syntax

'Declaration
Function GetLocalRegistryRootEx ( _
    dwRegType As UInteger, _
    <OutAttribute> ByRef pdwRegRootHandle As UInteger, _
    <OutAttribute> ByRef pbstrRoot As String _
) As Integer
int GetLocalRegistryRootEx(
    uint dwRegType,
    out uint pdwRegRootHandle,
    out string pbstrRoot
)
int GetLocalRegistryRootEx(
    [InAttribute] unsigned int dwRegType, 
    [OutAttribute] unsigned int% pdwRegRootHandle, 
    [OutAttribute] String^% pbstrRoot
)
abstract GetLocalRegistryRootEx : 
        dwRegType:uint32 * 
        pdwRegRootHandle:uint32 byref * 
        pbstrRoot:string byref -> int
function GetLocalRegistryRootEx(
    dwRegType : uint, 
    pdwRegRootHandle : uint, 
    pbstrRoot : String
) : int

Parameters

  • 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.

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.

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);
}

.NET Framework Security

See Also

Reference

ILocalRegistry4 Interface

Microsoft.VisualStudio.Shell.Interop Namespace