Possible Duplicate:
Looking for C# registry class
Way to write on registry location
我正在尝试用 C# 编写一个程序,通过执行一些操作(清除临时文件夹、预取文件夹...等)来提高 Windows 的速度
但是为了使程序更强大,我需要编辑注册表值.. 我该怎么做?
最佳答案
您可能需要阅读此article
public string Read(string KeyName)
{
// Opening the registry key
RegistryKey rk = baseRegistryKey ;
// Open a subKey as read-only
RegistryKey sk1 = rk.OpenSubKey(subKey);
// If the RegistrySubKey doesn't exist -> (null)
if ( sk1 == null )
{
return null;
}
else
{
try
{
// If the RegistryKey exists I get its value
// or null is returned.
return (string)sk1.GetValue(KeyName.ToUpper());
}
catch (Exception e)
{
// AAAAAAAAAAARGH, an error!
ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
return null;
}
}
}
关于c# - 如何通过 C# 代码编辑 Windows 中的注册表值(regedit)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11485093/