The process accepts the return code of the process end pass

Source: Internet
Author: User

In the project I want to implement a function: a process to create a B process run, through the end of B process to return the error code to carry out the next process.

Referring to some of the online code, the final form of such an absolutely feasible solution. A process:

if (CreateProcess (null,m_file,null,null,true,create_new_process_group| CREATE_DEFAULT_ERROR_MODE,NULL,NULL,&SI,&PI)) {   //Wait until child process exits.  WaitForSingleObject (pi.hprocess, INFINITE);       GetExitCodeProcess (pi.hprocess, &exitcode);  Close process and thread handles.   CloseHandle (pi.hprocess);  CloseHandle (Pi.hthread); if (id_cancel = = ExitCode) break;}

In the B process, send the Wm_quit message via PostQuitMessage (exit), and then get the error code via WPARAM

while (Msg.message!=wm_quit) {if (PeekMessage (&msg, NULL, 0U, 0U, Pm_remove)) {//Handles external message translatemessage (&MSG); DispatchMessage (&msg);} Else{}}}return Msg.wparam;


The process accepts the return code of the process end pass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.