16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 13:59:19 +02:00

extcam workarounds: hide console, wait for recorder process to terminate

This commit is contained in:
milek7
2019-10-12 23:18:16 +02:00
parent b9791a6699
commit b48daaf890
2 changed files with 7 additions and 3 deletions

View File

@@ -55,13 +55,12 @@ piped_proc::piped_proc(std::string cmd)
siStartInfo.hStdOutput = pipe_wr; siStartInfo.hStdOutput = pipe_wr;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES; siStartInfo.dwFlags |= STARTF_USESTDHANDLES;
if (!CreateProcessA(NULL, (char*)cmd.c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &process)) { if (!CreateProcessA(NULL, (char*)cmd.c_str(), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &siStartInfo, &process)) {
ErrorLog("piped_proc: CreateProcess failed!"); ErrorLog("piped_proc: CreateProcess failed!");
return; return;
} }
if (process.hProcess) proc_h = process.hProcess;
CloseHandle(process.hProcess);
if (process.hThread) if (process.hThread)
CloseHandle(process.hThread); CloseHandle(process.hThread);
} }
@@ -72,6 +71,10 @@ piped_proc::~piped_proc()
CloseHandle(pipe_wr); CloseHandle(pipe_wr);
if (pipe_rd) if (pipe_rd)
CloseHandle(pipe_rd); CloseHandle(pipe_rd);
if (proc_h) {
WaitForSingleObject(proc_h, INFINITE);
CloseHandle(proc_h);
}
} }
size_t piped_proc::read(unsigned char *buf, size_t len) size_t piped_proc::read(unsigned char *buf, size_t len)

View File

@@ -17,6 +17,7 @@ private:
#ifdef __unix__ #ifdef __unix__
FILE *file = nullptr; FILE *file = nullptr;
#elif _WIN32 #elif _WIN32
HANDLE proc_h = nullptr;
HANDLE pipe_rd = nullptr; HANDLE pipe_rd = nullptr;
HANDLE pipe_wr = nullptr; HANDLE pipe_wr = nullptr;
#endif #endif