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

Read Registry using C#

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

For insert:

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

I hope that helps.


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

About the Author


Colombia Colombia
No Biography provided

Comments and Discussions

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