Click here to Skip to main content
12,818,816 members (29,233 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 5 Dec 2011

Read Registry using C#

, 5 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to read a key from the Windows Registry.

This C# code snippet reads a key from 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!");
    Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey"));


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 Contains no explanation. Better alte... Pin
Ansgar Hellwig12-Dec-11 21:57
memberAnsgar Hellwig12-Dec-11 21:57 
QuestionAccess is denied. Pin
kami513-Dec-11 6:17
memberkami513-Dec-11 6:17 

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
Web02 | 2.8.170308.1 | Last Updated 5 Dec 2011
Article Copyright 2011 by Denno.Secqtinstien
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid