Click here to Skip to main content
15,881,588 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Read Registry using C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
7 Dec 2011CPOL 5.8K   3  
This is the code that I use:For lookup:RegistryKey rkn = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test");dwResult = rkn.GetValue("Preferences");For update:RegistryKey rkn = Registry.LocalMachine.CreateSubKey(szKeyPath); dwResult = rkn.ValueCount;rkn.SetValue(szKey,...

This is the code that I use:


For lookup:


C#
RegistryKey rkn  = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test");
dwResult = rkn.GetValue("Preferences");

For update:


C#
RegistryKey rkn  = Registry.LocalMachine.CreateSubKey(szKeyPath);             
dwResult = rkn.ValueCount;
rkn.SetValue(szKey, szValue);

For insert:


C#
RegistryKey rkn = Registry.LocalMachine.CreateSubKey("Software\\Test");
rkn.SetValue("Preferences1", "xxxx");

I hope that helps.

License

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


Written By
Colombia Colombia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --