在C#中操作登錄檔
using Microsoft.Win32;
using System.Diagnostics;
private void Access_Registry()
{
// 在HKEY_LOCAL_MACHINESoftware下建立一新鍵,起名為MCBInc
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", true);
// 增加一個子鍵
RegistryKey newkey = key.CreateSubKey("MCBInc");
// 設定此子鍵的值
newkey.SetValue("MCBInc", "NET Developer");
// 從登錄檔的其他地方獲取資料
// 找出你的CPU
RegistryKey pRegKey = Registry.LocalMachine;
pRegKey = pRegKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor");
Object val = pRegKey.GetValue("VendorIdentifier");
Debug.WriteLine("The central processor of this machine is:"+ val);
// 刪除鍵值
RegistryKey delKey = Registry.LocalMachine.OpenSubKey("Software", true);
delKey.DeleteSubKey("MCBInc");
}