CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002

    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 );



    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );

    Any ideas?

  2. #2
    Join Date
    May 2000
    KY, USA
    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.