HOWTO: Use RegOpenCurrentUser to Map to the User for the Currently Loaded HiveID: Q229675
|
You can access registry values for multiple users in your application by loading each user's hive programmatically. Use the RegOpenCurrentUser API function to retrieve a handle to the HKEY_CURRENT_USER key for the user that the current thread is impersonating.
HKEY_CURRENT_USER maps to the root of the current user's hive. The value of HKEY_CURRENT_USER does not change with the security context when another user's hive is loaded. In previous versions of Windows there was no safe way to access registry values for another user. You had to use RegCloseKey() and RegOpenKeyEx to remap HKEY_CURRENT_USER to the desired user's hive.
The RegOpenCurrentUser API function is new to Windows 2000, and provides a safe way to retrieve registry information about the user that the current thread is impersonating. RegOpenCurrentUser opens the key representing your thread's token, or Default if the profile isn't loaded.
For additional information about loading another user's hive, please see the following article(s) in the Microsoft Knowledge Base:
Q168877 HOWTO: Load a User's Hive Programmatically
Q199190 Reference Another User's Hive Through HKEY_CURRENT_USER
Additional query words: compatguidestability
Keywords : kbWinOS2000 kbSDKWin32 kbGrpKernBase
Version : winnt:
Platform : winnt
Issue type : kbhowto
Last Reviewed: May 25, 1999