WINSERVICE

private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
        {
            ManagementBaseObject inPar
= null;
            ManagementClass mc
= new ManagementClass("Win32_Service");
           
foreach (ManagementObject mo in mc.GetInstances())
            {
               
if (mo["Name"].ToString() == "服务名")
                {
                    inPar
= mo.GetMethodParameters("Change");
                    inPar[
"DesktopInteract"] = true;
                    mo.InvokeMethod(
"Change", inPar, null);
                }
            }     
  }

posted @ 2012-09-11 07:09  心际迷航  阅读(191)  评论(0编辑  收藏  举报