Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai all,

i am running the service in system account..

can i read the current logged in user registry(HEKY_CURRENT_USER)

how can i read the currently logged in user registry using the service running on the system account?
Posted
Comments
Chuck O'Toole 21-Dec-11 8:49am    
Consider two people using remote desktop to log into a server. On that server, define what you mean by "currently logged in user", there are two distinct ones.
@BangIndia 21-Dec-11 8:52am    
hai friend.

Sorry man i am not mention the requirement properly..
In xp sp2 .. only one person can login at a time..
That time i need the currently logged-in user registry..
we can do that?
sorry for question man..
Addy Tas 21-Dec-11 9:29am    
maybe a stupid question but; why? If you need to store something as a service you can always use the HKLM. if you need the HKCU you'll kindly need to ask the user for a token so you can impersonate him (see ImpersonateLoggedOnUser) but when you are doing that you might as well have a process running in the users space that can access the HKCU....

HKEY_CURRENT_USER is a link to one of the entries under HKEY_USERS and is set in the user registry space at logon. I am not sure that that link is available to a service running under a different account. A simple piece of additional code in your service program should soon be able to tell you.
 
Share this answer
 
 
Share this answer
 
Since multiple users may have logged on ,use WTSEnumerateSessions to get a list of all the sessions and exclude session 0 from it.Next,use WTSQueryUserToken to obtain the user's sid and format it into a string by ConvertSidToStringSid.
You should get something like S-1-5-21-3853930826-1272693629-3426184057-501.Appending it to HKEY_USERS\ and you will get the key name you want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900