C#操作注冊(cè)表簡(jiǎn)單方法實(shí)現(xiàn)
作者:佚名
C#操作注冊(cè)表簡(jiǎn)單方法實(shí)現(xiàn)主要向你介紹了C#操作注冊(cè)表的一個(gè)簡(jiǎn)單的過(guò)程,希望對(duì)你了解和學(xué)習(xí)C#操作注冊(cè)表有所幫助。
C#操作注冊(cè)表方面前言:使用VC,VB等語(yǔ)言操作注冊(cè)表的例子已經(jīng)有很多了,其實(shí)在C#操作注冊(cè)表更加的簡(jiǎn)單方便。下面的例子就提供了在C#里操作注冊(cè)表的方法:
- using Microsoft.Win32;
- //C#操作注冊(cè)表
- using System.Diagnostics;
- private void Access_Registry()
- {
- // 在HKEY_LOCAL_MACHINESoftware下建立一新鍵,起名為MCBInc
- RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", true);
- // 增加一個(gè)子鍵
- RegistryKey newkey = key.CreateSubKey("MCBInc");
- // 設(shè)置此子鍵的值
- newkey.SetValue("MCBInc", "NET Developer");
- // 從注冊(cè)表的其他地方獲取數(shù)據(jù)
- //C#操作注冊(cè)表
- // 找出你的CPU
- RegistryKey pRegKey = Registry.LocalMachine;
- pRegKey = pRegKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor");
- Object val = pRegKey.GetValue("VendorIdentifier");
- Debug.WriteLine("The central processor of this machine is:"+ val);
- // 刪除鍵值 ,C#操作注冊(cè)表
- RegistryKey delKey = Registry.LocalMachine.OpenSubKey("Software", true);
- delKey.DeleteSubKey("MCBInc");
- }
C#操作注冊(cè)表的簡(jiǎn)單例子就向你講解到這里,希望對(duì)你學(xué)習(xí)和了解C#操作注冊(cè)表有所幫助。
【編輯推薦】
責(zé)任編輯:仲衡
來(lái)源:
builder.com.cn