Solved

Interprocess communication !!!

Posted on 1998-10-21
2
161 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
Comment Utility
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
Comment Utility
Thank you very much.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
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…
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.

763 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

8 Experts available now in Live!

Get 1:1 Help Now