Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何确定services.msc管理单元是否加载到mmc控制台?_C++_Windows_Wix_Windows Installer_Mmc - Fatal编程技术网

C++ 如何确定services.msc管理单元是否加载到mmc控制台?

C++ 如何确定services.msc管理单元是否加载到mmc控制台?,c++,windows,wix,windows-installer,mmc,C++,Windows,Wix,Windows Installer,Mmc,我需要在程序卸载时提示用户关闭services.msc管理单元。我如何做到这一点?您需要编写自定义操作才能做到这一点。您可以使用检查services.msc是否加载到mmc中 [CustomAction] public static ActionResult CustomAction1(Session session) { foreach (Process getProcess in Process.GetProcesses()) {

我需要在程序卸载时提示用户关闭services.msc管理单元。我如何做到这一点?

您需要编写自定义操作才能做到这一点。您可以使用检查services.msc是否加载到mmc中

  [CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
        foreach (Process getProcess in Process.GetProcesses())
        {
            if (getProcess.ProcessName.Contains("mmc"))
            {
                if (getProcess.MainWindowTitle == "Services")
                {
                    session["SERVICES_MSC"] = "Running";
                    break;
                }
            }
        }

        return ActionResult.Success;
    }
调用卸载中的自定义操作,并基于服务\u MSC属性停止卸载

<Binary Id="Check_Services" SourceFile="..\TestProject\bin\Release\TestProject.CA.dll" />
<CustomAction Id="CHECK_SERVICES" BinaryKey="Check_Services" DllEntry="CustomAction1" Return="check" />

<CustomAction Id="STOP_INSTALLATION" Error="Services.msc is running.Please close that Window before uninstall the setup." />

在安装执行序列中,调用自定义操作

  <Custom Action="CHECK_SERVICES" After="InstallValidate">REMOVE ~= "ALL"</Custom>
  <Custom Action="STOP_INSTALLATION" After="CHECK_SERVICES">(REMOVE ~= "ALL") AND SERVICES_MSC</Custom>
REMOVE~=“全部”
(删除所有)和服务

谢谢。但若您首先运行mmc,然后通过文件->添加/删除管理单元加载服务小程序,并将焦点保留在控制台根目录上,那个么窗口标题将不包含“服务”。此外,小程序的名称可能被本地化为其他语言。您的目标是什么?请参阅,有时由于服务小程序正在运行,我的服务无法注册。这是一个有趣的问题。我没有现成的答案。有两种可能的非独占方法:1)帮助卸载程序用户了解卸载不应继续/在所有进程释放服务句柄之前不会完全完成,或2)帮助安装程序用户了解,除非所有进程释放计划删除的服务句柄,否则安装无法继续/将失败。检测(1)可能更难,但可以缩小到仅检测服务管理单元,正如您所建议的那样。检测(2)仍需要自定义操作。