c# - 如何通过 C# 代码编辑 Windows 中的注册表值(regedit)?

标签 c# windows regedit

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/

相关文章:

.net - 从注册表中检索 Windows 密码提示

linux - Unity3D 项目向导项目列表存储在 Linux/Mac 上的什么位置?

c# - 如何从 Selenium 中的 href 链接获取属性值

c# - 捕获异步 lambda 异常

c# - 如何在 WPF 进度条中使用图像?

c - 如何获取给定文件的 LBA 范围?

windows - 从 WlanEnumInterfaces 的 GUID 到硬件 ID、驱动程序版本等

delphi - 有没有人写过一些 delphi 代码来实现 REGJUMP 的功能?

c# - 为什么在同一个类中使用构造函数参数时可以访问私有(private)属性

c++ - 如何在Windows(C++)中创建过程以运行另一部分代码?