3bool execWithConsole(
const std::wstring& childExePath,
const std::wstring& selfDirPath,
int consoleStatus)
8 PROCESS_INFORMATION pi;
9 ZeroMemory(&si,
sizeof(si));
11 ZeroMemory(&pi,
sizeof(pi));
14 HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
15 HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
16 HANDLE hStdErr = GetStdHandle(STD_ERROR_HANDLE);
19 SetHandleInformation(hStdIn, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
20 SetHandleInformation(hStdOut, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
21 SetHandleInformation(hStdErr, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
24 si.dwFlags |= STARTF_USESTDHANDLES;
25 si.hStdInput = hStdIn;
26 si.hStdOutput = hStdOut;
27 si.hStdError = hStdErr;
30 std::wstring commandLine = childExePath;
33 std::wcout << L
"Application starting.\n\rPlease wait...\n\r" << std::endl;
47 std::wcerr << L
"CreateProcessW failed (" << GetLastError() << L
")." << std::endl;
52 WaitForSingleObject(pi.hProcess, INFINITE);
55 CloseHandle(pi.hProcess);
56 CloseHandle(pi.hThread);
58 if (consoleStatus == 0)
60 std::wcout << L
"Child process finished.\n\rPress any key to exit console..." << std::endl;
63 else if (consoleStatus == 1)
65 std::wcout << L
"Finish\r\n" << std::endl;
72bool execWitoutConsole(
const std::wstring& childExePath,
const std::wstring& selfDirPath)
77 PROCESS_INFORMATION pi;
78 ZeroMemory(&si,
sizeof(si));
80 ZeroMemory(&pi,
sizeof(pi));
83 si.dwFlags = STARTF_USESHOWWINDOW;
84 si.wShowWindow = SW_HIDE;
87 std::wstring commandLine = childExePath;
103 MessageBoxW(NULL, (L
"Failed to launch Python script. Error code: " + std::to_wstring(GetLastError())).c_str(), L
"Launcher Error", MB_OK | MB_ICONERROR);