Export (0) Print
Expand All

RegOpenUserClassesRoot function

Retrieves a handle to the HKEY_CLASSES_ROOT key for a specified user. The user is identified by an access token. The returned key has a view of the registry that merges the contents of the HKEY_LOCAL_MACHINE\Software\Classes key with the contents of the Software\Classes keys in the user's registry hive. For more information, see HKEY_CLASSES_ROOT Key.

Syntax


LONG WINAPI RegOpenUserClassesRoot(
  _In_        HANDLE hToken,
  _Reserved_  DWORD dwOptions,
  _In_        REGSAM samDesired,
  _Out_       PHKEY phkResult
);

Parameters

hToken [in]

A handle to a primary or impersonation access token that identifies the user of interest. This can be a token handle returned by a call to LogonUser, CreateRestrictedToken, DuplicateToken, DuplicateTokenEx, OpenProcessToken, or OpenThreadToken functions.

The handle must have TOKEN_QUERY access. For more information, see Access Rights for Access-Token Objects.

dwOptions

This parameter is reserved and must be zero.

samDesired [in]

A mask that specifies the desired access rights to the key. The function fails if the security descriptor of the key does not permit the requested access for the calling process. For more information, see Registry Key Security and Access Rights.

phkResult [out]

A pointer to a variable that receives a handle to the opened key. When you no longer need the returned handle, call the RegCloseKey function to close it.

Return value

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

The RegOpenUserClassesRoot function enables you to retrieve the merged HKEY_CLASSES_ROOT information for users other than the interactive user. For example, the server component of a client/server application could use RegOpenUserClassesRoot to retrieve the merged information for a client.

RegOpenUserClassesRoot fails if the user profile for the specified user is not loaded. When a user logs on interactively, the system automatically loads the user's profile. For other users, you can call the LoadUserProfile function to load the user's profile. However, LoadUserProfile can be very time-consuming, so do not call it for this purpose unless it is absolutely necessary to have the user's merged HKEY_CLASSES_ROOT information.

Applications running in the security context of the interactively logged-on user do not need to use RegOpenUserClassesRoot. These applications can call the RegOpenKeyEx function to retrieve a merged view of the HKEY_CLASSES_ROOT key for the interactive user.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

See also

LoadUserProfile
RegCloseKey
Registry Functions
Registry Overview
RegOpenKeyEx

 

 

Community Additions

ADD
Show:
© 2014 Microsoft