日期:2014-05-18 浏览次数:20975 次
服务安装后事件 这样就可以了 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() == "KeyboardService") { inPar = mo.GetMethodParameters("Change"); inPar["DesktopInteract"] = true; mo.InvokeMethod("Change", inPar, null); } } }*/
------解决方案--------------------
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);
}
}
}*/