第1个回答 2009-12-25
读写注册表的类
using Microsoft.Win32;
参考下吧
public static bool InitEPath()
{
RegistryKey pregkey;
try
{
pregkey = Registry.LocalMachine.OpenSubKey("SYSTEM", true).OpenSubKey("ControlSet001", true).OpenSubKey("Control", true).OpenSubKey("Session Manager", true).OpenSubKey("Environment", true);
if (null != pregkey)
{
if (null == pregkey.GetValue(keys))
{
pregkey.SetValue(keys, "TRUE");
pregkey.Close();
return true;
}
}
}
catch
{
}
return false;
}
Registry.LocalMachine 打开注册表中的 HKEY_LOCAL_MACHINE ,
OpenSubKey("SYSTEM", true). 打开HKEY_LOCAL_MACHINE 中的SYSTEM项,然后下面的项是一个一个下去的。本回答被提问者采纳