1
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = _T("runas");
shExecInfo.lpFile = filePath;
shExecInfo.lpParameters = NULL;
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_MAXIMIZE;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
如果文件路徑是從Internet下載的臨時文件,ShellExecuteEx會失敗。但是,如果filepath是「記事本」之類的普通文件名,則它可以工作。如何安裝臨時安裝程序文件?
我得出結論,shellexecute需要正確的擴展名,但正常的特權應用程序無法將可執行文件寫入系統部分,如c:\ users \ xxx \ local \ temp \ xxx.exe。
錯誤代碼是ERROR_NO_ASSOCIATION。
請幫我解決這個矛盾。