您的位置:首页 > 其它

windows中允许服务与桌面交互的更改方法示例

2014-02-25 14:53 836 查看
protected override void OnCommitted(System.Collections.IDictionary savedState){base.OnCommitted(savedState);//将服务更改为允许桌面交互模式ConnectionOptions coOptions = new ConnectionOptions();coOptions.Impersonation = ImpersonationLevel.Impersonate;ManagementScope mgmtScope = new System.Management.ManagementScope(@"root\CIMV2", coOptions);mgmtScope.Connect();ManagementObject wmiService;wmiService = new ManagementObject("Win32_Service.Name='这里是当前服务名'");ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");InParam["DesktopInteract"] = true;ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam, null);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息