我有一个C#应用程序,我正在尝试通过注册表编辑服务.我正在使用需要管理员权限才能运行我的应用程序的清单文件.尽管如此,这段代码抛出System.UnauthorizedAccessException: Cannot write to the registry key:
RegistryKey key = Registry.LocalMachine.OpenSubKey ("SYSTEM\\CurrentControlSet\\services\\Tomcat7");
key.SetValue ("Start", 2, RegistryValueKind.DWord);
Run Code Online (Sandbox Code Playgroud)
有没有人对如何解决这个问题有任何想法?
小智 24
Plz遵循以下代码,请注意其他true参数:
RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\Tomcat7",true);
key.SetValue("Start", 2, RegistryValueKind.DWord);
Run Code Online (Sandbox Code Playgroud)