createProcess questions
-
1. The foll code is what I will use.
STARTUPINFO si = { sizeof(STARTUPINFO) }; PROCESS\_INFORMATION pi; // Create the process if (!::CreateProcess(NULL, "your.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { AfxMessageBox("Error starting the process!"); return; } // Wait till it ends ::WaitForSingleObject(pi.hProcess, INFINITE); // Clean up ::CloseHandle(pi.hProcess); ::CloseHandle(pi.hThread);
Q1. If the exe launched is a windows app that needs some stuff done by the user, and then it is exited, will the WaitForSIngleObject will come back only after this launched windows app terminates? Q2. If the launched process awaits the user, but he decides to press some other button on the main program (not the launched program) will the button respond? Or will the main app be unresponsive until the user has dealt with the launched app and exited it? Appreciate your help, ns
-
1. The foll code is what I will use.
STARTUPINFO si = { sizeof(STARTUPINFO) }; PROCESS\_INFORMATION pi; // Create the process if (!::CreateProcess(NULL, "your.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { AfxMessageBox("Error starting the process!"); return; } // Wait till it ends ::WaitForSingleObject(pi.hProcess, INFINITE); // Clean up ::CloseHandle(pi.hProcess); ::CloseHandle(pi.hThread);
Q1. If the exe launched is a windows app that needs some stuff done by the user, and then it is exited, will the WaitForSIngleObject will come back only after this launched windows app terminates? Q2. If the launched process awaits the user, but he decides to press some other button on the main program (not the launched program) will the button respond? Or will the main app be unresponsive until the user has dealt with the launched app and exited it? Appreciate your help, ns
Q1: Yes Q2: Depends. If your code is called from the application thread (the one with the message loop), then yes it will block your app until the launched app exits. But if you call it from an other thread then your app will not block. Magnus