Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Read Registry using C#

, 7 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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:

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, szValue);

For insert:

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)

Share

About the Author

morningstar1710

Colombia Colombia
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150129.1 | Last Updated 7 Dec 2011
Article Copyright 2011 by morningstar1710
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid