Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Interprocess communication !!!

Posted on 1998-10-21
2
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

718 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