CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    30

    How to terminate a process?



    How do I terminate a process which was created by CreateProcess function?

    Here is what I got so far:

    void CMFPView::OnFaxEditor()

    {

    STARTUPINFO sinfo = {sizeof(sinfo), NULL, NULL, NULL, NULL, NULL, NULL,

    NULL, NULL, NULL, NULL, STARTF_USESHOWWINDOW, SW_SHOW, 0, NULL,

    NULL, NULL, NULL};

    PROCESS_INFORMATION pinfo;

    CreateProcess(NULL, "d:\\mfp\\faxNumStg-VB\\faxNumStg.exe",

    NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE,NULL,NULL,

    &sinfo,&pinfo);

    }

    The faxNumStg AP doesn't terminate unless user choose to close the AP. If user did not close faxNumStg AP, how do I

    terminate faxNumStg AP automatically when the calling AP was terminated. Any suggestion would be greatly appreciated.

    Thanks in advance.


    Best Regards,

    Tiffany Chen

  2. #2
    Join Date
    Apr 1999
    Posts
    24

    Re: How to terminate a process?



    You could use


    TerminateProcess(pinfo.hProcess,nExitCode);


    (and remember to close the handles pinfo.hProcess and pinfo.hThread).


    This may be a bit abrupt though! Another alternative is to use FindWindow to get the main window to the FaxEditor and try sending a WM_CLOSE or WM_QUIT message to it. If this works, it will give the program a chance to shutdown a bit more gracefully.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured