做个记录

  base.OnAfterInstall(e.SavedState);

            ManagementObject wmiService
= null;
ManagementBaseObject InParam
= null;
           
try
            {
                wmiService
= new ManagementObject(string.Format("Win32_Service.Name='{0}'", Constants.ServiceName));
                InParam
= wmiService.GetMethodParameters("Change");
                InParam[
"DesktopInteract"] = true;
                wmiService.InvokeMethod(
"Change", InParam, null);
            }
           
finally
            {
               
if (InParam != null)
                    InParam.Dispose();
               
if (wmiService != null)
                    wmiService.Dispose();
            }
posted @ 2012-09-20 00:54  心际迷航  阅读(176)  评论(0编辑  收藏  举报