Click here to Skip to main content
Click here to Skip to main content

Tagged as

Writing Registry using C#

, 13 Dec 2011 CPOL
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
Follow on   Twitter

Comments and Discussions

GeneralReason for my vote of 1 'Cos you can't vote zero ;-) PingroupPaul @ The Computer Station19-Dec-11 7:04 
GeneralReason for my vote of 1 why ? PinmemberSelvin13-Dec-11 9:43 
GeneralReason for my vote of 1 no explanation PinmemberToPr13-Dec-11 3:10 
GeneralThis is a repost of <a href=" PinmemberKim Togo12-Dec-11 23: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... PinmemberAnsgar Hellwig12-Dec-11 21:58 
GeneralReason for my vote of 1 Is this article adding any value ? PinmemberYvesDaoust12-Dec-11 21:32 

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

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

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