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

时间:2017-04-20 20:09:18   收藏:0   阅读:2339

阻塞:

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表示管理员权限调用

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!