ShellExecuteEx 阻塞和异步调用进程的两种方法

阻塞:

SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = (LPCWSTR)newAppPath.utf16(); // _telegramPath.toLocal8Bit().constData();
ShExecInfo.lpParameters = L"";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);

异步:

ShellExecuteA(NULL, "open", _telegramPath.toLocal8Bit().data(),telegramStartParm.c_str(), NULL, SW_SHOWNORMAL); 

 

备注:SW_SHOWNORMAL表示管理员权限调用

posted on 2017-04-20 17:52  阿兴的平凡世界  阅读(905)  评论(0编辑  收藏  举报

导航