取消我經歷的ShellExecuteEx啓動EXE:如何檢測是否通過的ShellExecuteEx推出由UAC
tstring sPath = _T("C:\\Test\\MyApp.exe");
tstring sArgs = _T("/S");
SHELLEXECUTEINFO lpExecInfo = {0,};
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
lpExecInfo.lpFile = sPath.c_str();
lpExecInfo.fMask=SEE_MASK_NOASYNC ;
lpExecInfo.hwnd = NULL;
lpExecInfo.lpVerb = NULL;
lpExecInfo.lpParameters = sArgs.c_str();
lpExecInfo.lpDirectory = NULL;
lpExecInfo.nShow = SW_SHOWNORMAL;
if (!ShellExecuteEx(&lpExecInfo)) {
// handle the error
throw CException("Cannot launch an application");
}
int nRes = (int)lpExecInfo.hInstApp; // nRes = 42
DWORD dwErr = GetLastError(); // dwErr = 0
我怎樣才能檢測是否啓動由UAC取消?在這種情況下ShellExecuteEx成功(hInstApp = 42,GetLastError返回0)。
感謝
維塔利,當有問題後作爲評論發佈(如這一個)或編輯您的原始文章。如果它仍然是一個問題,請不要將其作爲答案發布。 – RedX