Microsoft KB Archive/229675

{|
 * width="100%"|

HOWTO: Use RegOpenCurrentUser to Map to the User for the Currently Loaded Hive

 * }

Q229675

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * the operating system: Microsoft Windows 2000

-

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

MORE INFORMATION
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.