当通过ShellExecuteEx功能启动时,安装屏蔽窗口没有出现在顶部

Install-Shield window is not coming on top when launched through ShellExecuteEx function

本文关键字:窗口 顶部 屏蔽 安装 ShellExecuteEx 功能 启动      更新时间:2023-10-16

我正在尝试通过使用下面的代码

启动通过install-shield制作的setup.exe
DWORD ChildProcess(LPCSTR exePath, LPCSTR lpCmdLine ,BOOL showDialog, char* workingDir, BOOL bParentWait )
{
    CWnd * handle = AfxGetMainWnd (); //handle to the main dialog box of mfc application
    DWORD dwExitCode = -1;
    SHELLEXECUTEINFO ShExecInfo = {0};
    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
    ShExecInfo.lpVerb = "open";
    ShExecInfo.lpFile = exePath; //setup.exe path, installer exe
    if(bParentWait)
    {
        ShExecInfo.lpParameters =   lpCmdLine;
        ShExecInfo.nShow = SW_MINIMIZE;
    }
    else
    {
        ShExecInfo.nShow = SW_SHOW;
        ShExecInfo.lpParameters =   NULL;
    }
    ShExecInfo.lpDirectory = workingDir;
    ShExecInfo.hInstApp = NULL; 
    if (ShellExecuteEx(&ShExecInfo))
    {
        if(bParentWait)
        {
            handle->ShowWindow(SW_MINIMIZE);
            WaitForSingleObject(ShExecInfo.hProcess,INFINITE);  
            if(showDialog){
                handle->ShowWindow(SW_RESTORE);
            }
            GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);
        }
        else
        {
            CloseHandle(ShExecInfo.hProcess);
            dwExitCode = 0;
        }
    }
    return dwExitCode;
}

问题是启动的安装程序窗口没有出现在顶部。如有任何帮助,我将不胜感激。

谢谢

我相信你的问题是因为setup.exe产生了另一个执行UI序列的进程(从而显示窗口)。