在 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);
// "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);