Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
 Friday, August 12, 2005

Here is a quick example on how to access the registry in .NET. This example just loops thru each entry in the selected folder in the registry and prints the gathered information to the console.

using System;
using Microsoft.Win32;

namespace Acessing_Registry
{
    class AccessingRegistry
    {
        [STAThread]
        static void Main(string[] args)
        {
            //create a object that would reference to the parent registry type folder
            RegistryKey regKey = Registry.LocalMachine;
            //assign a path in the registry to read
            regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
            //loop thru each entry in the registry
            foreach(string keyName in regKey.GetValueNames())
            {
                //read and display that keyName's value
                Console.WriteLine(keyName + ":" + regKey.GetValue(keyName));
            }
            //display the output to the screen
            Console.ReadLine();
        }
    }
}

The important thing to note on this example is that we first declare the location on where to read the key and reference that key by its name to get the underlying value/s.

Friday, August 12, 2005 7:55:32 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.NET
Tracked by:
"spamfreeforum" (online) [Trackback]
"coco chanel handbag" (online) [Trackback]
"davidoff cigars" (online) [Trackback]
"thomas myspace editor" (online) [Trackback]
"baked red snapper" (online) [Trackback]
"koa camp grounds" (online) [Trackback]
Comments are closed.
On this page
Archive
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Keith Rull
Sign In
Statistics
Total Posts: 259
This Year: 56
This Month: 2
This Week: 1
Comments: 111
Themes
Pick a theme:
Ads
All Content © 2008, Keith Rull
DasBlog theme 'Business' created by Christoph De Baene (delarou)