The DETACHED_PROCESS flag documentation contains
For console processes, the new process does not inherit the parent console (default)
This means: if you have a console process and you start a new one, it will not inherit its parent console.
If you don't have a console process, you have nothing to worry about.
CreateProcess creates a child process, but does not wait for the child process to complete , so you are all set.
, CreateProcess, WaitForSingleObject
:
STARTUPINFO info = { sizeof(info) };
PROCESS_INFORMATION processInfo;
if (CreateProcess(L"C:\\myapp.exe", L"", NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) {
::WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
STARTUPINFO info = { sizeof(info) };
PROCESS_INFORMATION processInfo;
if (CreateProcess(L"C:\\myapp.exe", L"", NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo)) {
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
, 2 . , .