您的位置:首页 > 编程语言 > C语言/C++

C++以阻塞的方式调用外部exe程序,等待其运行结束

2014-07-17 16:02 507 查看
        SHELLEXECUTEINFO ShExecInfo = {0};
        ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
        ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
        ShExecInfo.hwnd = NULL;
        ShExecInfo.lpVerb = L"open";//多种类别有 "explorer" "print" 等
        ShExecInfo.lpFile = EXE_FILE;//exe 路径    
        ShExecInfo.lpParameters = pbuffer;//参数
        ShExecInfo.lpDirectory = NULL;
        ShExecInfo.nShow = SW_HIDE;//
        ShExecInfo.hInstApp = NULL;
        ShellExecuteEx(&ShExecInfo);

        WaitForSingleObject(ShExecInfo.hProcess, INFINITE);//等待完成   第二个参数是超时时间(毫秒)超时后返回超时代码    

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: