Solved

Interprocess communication !!!

Posted on 1998-10-21
2
162 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now