Platform SDK: Registry |
The RegOpenCurrentUser function retrieves a handle to the HKEY_CURRENT_USER key for the user the current thread is impersonating.
LONG RegOpenCurrentUser( REGSAM samDesired, // access rights PHKEY phkResult // handle to open key );
Value | Meaning |
---|---|
KEY_CREATE_LINK | Permission to create a symbolic link. |
KEY_CREATE_SUB_KEY | Permission to create subkeys. |
KEY_ENUMERATE_SUB_KEYS | Permission to enumerate subkeys. |
KEY_EXECUTE | Permission for read access. |
KEY_NOTIFY | Permission for change notification. |
KEY_QUERY_VALUE | Permission to query subkey data. |
KEY_SET_VALUE | Permission to set subkey data. |
KEY_ALL_ACCESS | Combines the KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, KEY_CREATE_SUB_KEY, KEY_CREATE_LINK, and KEY_SET_VALUE access rights, plus all the standard access rights except SYNCHRONIZE. |
KEY_READ | Combines the STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY access rights. |
KEY_WRITE | Combines the STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, and KEY_CREATE_SUB_KEY access rights. |
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.
The HKEY_CURRENT_USER key is cached for all threads in a process. If the process is impersonating multiple users, RegOpenCurrentUser allows the threads to access the appropriate key.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winreg.h; include Windows.h.
Library: Use Advapi32.lib.