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

‘선언
Function GetLocalRegistryRootEx ( _
    dwRegType As UInteger, _
    <OutAttribute> ByRef pdwRegRootHandle As UInteger, _
    <OutAttribute> ByRef pbstrRoot As String _
) As Integer
‘사용 방법
Dim instance As ILocalRegistry4
Dim dwRegType As UInteger
Dim pdwRegRootHandle As UInteger
Dim pbstrRoot As String
Dim returnValue As Integer

returnValue = instance.GetLocalRegistryRootEx(dwRegType, _
    pdwRegRootHandle, pbstrRoot)
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

ILocalRegistry4 Members

Microsoft.VisualStudio.Shell.Interop Namespace