基本上,我在代码中提供的路径下的注册表中有一个名为“Manufacturer”的密钥。
我想更改分配给该键的值,这应该比我在研究中找到的更简单
问题
当我检查注册表时,按键似乎根本没有改变。
它运行良好,没有错误。它实际上打印了我的完整'尝试',好像它成功了。
当我尝试'.GetValue()'方法时,它会返回我指定的值,就像程序一样。
我被告知该程序默认使用与我提供的路径不同的路径。 (Thanks)
我不知道如何防止这种情况......
//这是我的代码:
namespace OEMInfo
{
class Program
{
static void Main(string[] args)
{
String OEM = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\";
try
{
RegistryKey OEMKey = Registry.LocalMachine.OpenSubKey(OEM, true);
OEMKey.SetValue("Manufacturer", "TEST");
Console.WriteLine("The registry key has been switched\n-----------------------------------------");
Console.WriteLine("Press ENTER to continue.");
Console.ReadLine();
}
catch
{
Console.WriteLine("There was an error switching the registry key!\n-----------------------------------------");
Console.WriteLine("Press ENTER to continue.");
Console.ReadLine();
}
}
}
}
注意:我是新手,所以请耐心等待。