阻塞调用ShellExecute函数

来源:互联网 发布:网络工程研究生 知乎 编辑:程序博客网 时间:2024/04/25 03:05
           SHELLEXECUTEINFO si;
            ZeroMemory(&si, sizeof(si));
            si.cbSize = sizeof(si);
            si.fMask = SEE_MASK_NOCLOSEPROCESS;
            si.lpVerb = _T("open");
            si.lpFile = _T("notepad.exe");
            si.nShow = SW_SHOWNORMAL;

            ShellExecuteEx(&si);

            DWORD dwExitCode;
            GetExitCodeProcess(si.hProcess,&dwExitCode);
            while (dwExitCode == STILL_ACTIVE)
            {
                    Sleep((DWORD)5);
                    GetExitCodeProcess(si.hProcess, &dwExitCode);
            }

            CloseHandle(si.hProcess);
原创粉丝点击