C# 修改注册表 达到 Windows Services 启动 窗体应用程序

来源:互联网 发布:虎豹骑 优化 编辑:程序博客网 时间:2024/04/26 11:13


在  OnStart 函数 下 添加 如下代码

            //  [HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Service1]
            
//  "Type"=dword:00000110    Allow  service  to  interact  with  desktop
           
//   "Type"=dword:00000010    Deny  service  to  interact  with  desktop
            Microsoft.Win32.RegistryKey key = Registry.LocalMachine;
            Microsoft.Win32.RegistryKey key1 
= key.CreateSubKey("System//ControlSet001//Services//Service1");
            key1.SetValue(
"Type"272, Microsoft.Win32.RegistryValueKind.DWord);
原创粉丝点击