What is the difference: LoadUserProfile -vs- RegOpenCurrentUser
Posted
by Will5801
on Stack Overflow
See other posts from Stack Overflow
or by Will5801
Published on 2009-01-19T21:36:12Z
Indexed on
2010/04/10
13:03 UTC
Read the original article
Hit count: 485
These two APIs are very similar but it is unclear what the differences are and when each should be used (Except that LoadUserProfile is specified for use with CreateProcessAsUser which I am not using. I am simply impersonating for hive accesss).
LoadUserProfile http://msdn.microsoft.com/en-us/library/bb762281(VS.85).aspx
RegOpenCurrentUser http://msdn.microsoft.com/en-us/library/ms724894(VS.85).aspx
According to the Services & the Registry article: http://msdn.microsoft.com/en-us/library/ms685145(VS.85).aspx we should use RegOpenCurrentUser when impersonating.
But what does/should RegOpenCurrentUser do if the user profile is roaming - should it load it?
As far as I can tell from these docs, both APIs provide a handle to the HKEY_CURRENT_USER for the user the thread is impersonating. Therefore, they both "load" the hive i.e. lock it as a database file and give a handle to it for registry APIs.
It might seem that LoadUserProfile loads the user profile in the same way as the User does when he/she logs on, whereas RegOpenCurrentUser does not - is this correct? What is the fundamental difference (if any) in how these two APIs mount the hive?
What are the implications and differences (if any) between what happens IF
A user logs-on or logs-off while each of these impersonated handles is already in use?
A user is already logged-on when each matching close function (RegCloseKey and UnloadUserProfile) is called?
© Stack Overflow or respective owner