MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / ExecEx

Function ExecEx

shared/Exec.c:15–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15HRESULT ExecEx(LPSHELLEXECUTEINFO execInfo, BOOL wait, LPDWORD exitCode) {
16 if (wait) {
17 execInfo->fMask |= SEE_MASK_NOCLOSEPROCESS;
18 }
19
20 if (!ShellExecuteEx(execInfo)) {
21 return HRESULT_FROM_WIN32(GetLastError());
22 }
23
24 HRESULT hr = S_OK;
25
26 if (wait) {
27 if (execInfo->hProcess == NULL) {
28 hr = HRESULT_FROM_WIN32(GetLastError());
29 CHECK_HR(L"ShellExecuteEx didn't return a handle");
30 hr = E_FAIL;
31 }
32
33 WaitForSingleObject(execInfo->hProcess, INFINITE);
34
35 if (exitCode != NULL && GetExitCodeProcess(execInfo->hProcess, exitCode) == 0) {
36 hr = HRESULT_FROM_WIN32(GetLastError());
37 CHECK_HR(L"GetExitCodeProcess failed");
38 }
39
40 CloseHandle(execInfo->hProcess);
41 } else if (exitCode != NULL) {
42 *exitCode = 0;
43 }
44
45 return hr;
46}

Callers 3

PauseResumeNGenQueueFunction · 0.85
ViewLogFunction · 0.85
ExecFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected