-
February 28th, 2003, 06:31 AM
#1
Closing an external program programmatically
I want to be able to make an external program exit from my code.
I start the process for the executable, then I want to do something within my program. Then once that is done I want to close the external program.
My code at present:-
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
"PleaseWait.exe", // 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.
)
{
AfxMessageBox( "CreateProcess failed." );
}
// Would normally do this but I want to control when it exits
//WaitForSingleObject( pi.hProcess, INFINITE );
:::
// DO SOMETHING HERE
:::
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
Any ideas?
-
February 28th, 2003, 06:43 AM
#2
Take a look at this FAQ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|