Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends i am developing one windows application .

i am trying to write value in registry in following location

HKEY_USER\\S-1-5-21-2000478354-1214440339-682003330-1003\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall



in my system i know this path exactly


but i want to read this value while my application running in client system

from the above path i want to know how to get this following value

(S-1-5-21-2000478354-1214440339-682003330) in every system .

if i get command for this then it will be use full for me


thanking you
Posted

wrote:
from the above path i want to know how to get this following value
(S-1-5-21-2000478354-1214440339-682003330)

This value is called SID. SID is a unique user identifier. This is so windows still knows who you are even if you change your username. :)

To get the SID of the currently logged user you could try:
string username = String.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName);
System.Security.Principal.WindowsIdentity id = new System.Security.Principal.WindowsIdentity(username);
string sid = id.User.AccountDomainSid.ToString();


or:
System.Security.Principal.WindowsIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();
string sid = id.User.AccountDomainSid.ToString();


I hope this helps. :)
Regards
 
Share this answer
 
There are no commands for searching the registry that I know of. Why does the value you need change ?
 
Share this answer
 
Instead of using a hardcoded SID, why don't you use the Registry.CurrentUser[^] field to access the subkeys? This would provide a portable solution, which is what I assume you're going for.
 
Share this answer
 
v2

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