I have a console application that closes by capturing CTRL_CLOSE_EVENT message.
If I startup this application manually, and then close the DOS console window via the CLOSE [X] icon, the applications closes successfully.
I can verify that it closes successfully, because I can see the debug log file showing that it captured the CTRL_CLOSE_EVENT message.
Now here is where my problem is at. I have a test application that is suppose to launch the above console application, and then after peformming the proper test, it suppose to signal to the console application to close. However, I can't seem to get the console application to close programmatically.
Here's the code that is in the test application:
char TargetExec = "..\\debug\\FileBridgeApp.exe";
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if (CreateProcess( NULL, // No module name (use command line).
TargetExec, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
// Close process and thread handles.
CloseHandle( pi.hProcess ); // ******this does not close the application
CloseHandle( pi.hThread ); // ******this does not close the application
How can correctly signal to the application to close.