1.

How Can I Access The Registry From C# Code?

Answer»

By using the REGISTRY and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and DISPLAYS its value:
using System;using Microsoft.Win32;
class regTest
{
public STATIC void Main(String[] ARGS)
{
RegistryKey regKey;
Object value;
regKey = Registry.LocalMachine;
regKey = regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor ");
value = regKey.GetValue("VendorIdentifier");
Console.WriteLine("The central processor of this MACHINE is: {0}.", value);
}
}

By using the Registry and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and displays its value:
using System;using Microsoft.Win32;
class regTest
{
public static void Main(String[] args)
{
RegistryKey regKey;
Object value;
regKey = Registry.LocalMachine;
regKey = regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor ");
value = regKey.GetValue("VendorIdentifier");
Console.WriteLine("The central processor of this machine is: {0}.", value);
}
}



Discussion

No Comment Found