Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Interprocess communication !!!

Posted on 1998-10-21
2
Medium Priority
?
170 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 800 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

885 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