Click here to Skip to main content
13,197,342 members (29,970 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 5 Dec 2011

Writing Registry using C#

, 13 Dec 2011
Rate this:
Please Sign up or sign in to vote.
Writing Registry using C#

This C# code snippet writes a key to the Windows Registry.

WARNING: Do NOT play with the Registry. If you do not know what you are doing, you can cause any number of costly problems. Use this code at your own risk.

using Microsoft.Win32;
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey
if (masterKey == null)
   Console.WriteLine ("Null Masterkey!");
      masterKey.SetValue ("MyKey", "MyValue");
   catch (Exception ex)
      Console.WriteLine (ex.Message);


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


About the Author

Technical Lead Erls Corporation
India India
I am Dinesh kumar Choudhary by Name, a software Designer and Developer by Work, a Indian Hindu by Religion, Co-Founder of DSFoundation located at by profession, a Loving husband and a Caring Father by Relation.

I have a blog Website at DSFoundation is the Autonomous body to serve for the management of Local shops located at New Delhi, India. Now a days DSFoundation and its subsidiaries are managed by Erls Corporation, an Another initiative by me and my colleagues, in which i am the another CO-Founder of the Organization. Erls Corporation can be located at

You may also be interested in...


Comments and Discussions

GeneralReason for my vote of 1 'Cos you can't vote zero ;-) Pin
Paul @ The Computer Station19-Dec-11 6:04
groupPaul @ The Computer Station19-Dec-11 6:04 
GeneralReason for my vote of 1 why ? Pin
Selvin13-Dec-11 8:43
memberSelvin13-Dec-11 8:43 
GeneralReason for my vote of 1 no explanation Pin
ToPr13-Dec-11 2:10
memberToPr13-Dec-11 2:10 
GeneralThis is a repost of <a href=" Pin
Kim Togo12-Dec-11 22:18
memberKim Togo12-Dec-11 22:18 
This is a repost of

Please delete this tips and stick to the other tip Smile | :)
GeneralReason for my vote of 1 Contains no explanation. Plenty of b... Pin
Ansgar Hellwig12-Dec-11 20:58
memberAnsgar Hellwig12-Dec-11 20:58 
GeneralReason for my vote of 1 Is this article adding any value ? Pin
YvesDaoust12-Dec-11 20:32
memberYvesDaoust12-Dec-11 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 13 Dec 2011
Article Copyright 2011 by Denno.Secqtinstien
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid