Solved

Interprocess communication !!!

Posted on 1998-10-21
2
163 Views
Last Modified: 2010-04-02
Would you like help me how to comminicate interprocess ?
My problem is :
In my main program(A) I already actived another process(B) by WinExec() or CreateProcess() function and at this time my program A has to stop for waiting B process ends (exit the system or was killed by Windows). But I don't know when B process ends  is it return a value to my main A program ???
And how my program can capture that value to run at the rest of its ?
0
Comment
Question by:longlong
2 Comments
 
LVL 3

Accepted Solution

by:
stefanr earned 200 total points
ID: 1175734
Try something like this:

STARTUPINFO StartupInfo = { 0 };
StartupInfo.cb = sizeof(STARTUPINFO);

// Initialize StartupInfo with appropriate values.

PROCESS_INFORMATION ProcessInfo = { 0 };

if (::CreateProcess(lpszAppName, lpszCmdLine, NULL, NULL, FALSE, dwCreationFlags, NULL, NULL, &StartupInfo, &ProcessInfo))
{
   switch (::WaitForSingleObject(ProcessInfo.hProcess, dwMilliseconds))
   {
      case WAIT_OBJECT_0:
         // The process is terminated.
         {
            DWORD dwExitCode = 0;
            ::GetExitCodeProcess(ProcessInfo.hProcess, &dwExitCode); // You must have PROCESS_QUERY_INFORMATION access on NT.
         }
         break;

      case WAIT_TIMEOUT:
         // Fall through.
      default:
         // Timeout while waiting for process termination.
         break;
   }

   ::CloseHandle(ProcessInfo.hThread); // Don't forget!
   ::CloseHandle(ProcessInfo.hProcess); // Don't forget!
}

That doesn't work with WinExec, since it don't return any handles.
0
 

Author Comment

by:longlong
ID: 1175735
Thank you very much.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question