tags:

views:

140

answers:

2

I have a dialog based MFC application through which I have to call a .NET executable.

My question are:

  1. How will the MFC application know that the .NET executable is closed?
  2. if suppose a .Net executable process some information and want to convey the output to the MFC application, how can this be achieved.

Please help!!

+2  A: 

The MFC application can just wait for the .NET process to exit in the normal way - either using a wait handle or by polling it.

As for collecting output - the simplest mechanisms is likely to be for the .NET executable to write to a file, and then the MFC app can read it afterwards. It's crude but very easy to implement!

Jon Skeet
+1  A: 

1) Your MFC application can use CreateProcess() to run the .NET EXE and then use the GetExitCodeProcess() function to find out if it has finished. If it hasn't finished, this API returns STILL_ACTIVE(259).

2) If the .NET EXE outputs to the command line, you can read the output using the Standard Handle StdOut and StdErr. More information here.

Alternatively, invoke your .NET EXE via the Command Line like this:

ShellExecute("%SYSTEMROOT%\System32\Cmd.exe /C \"Path to your .NET EXE\" > %TEMP%\CaptureOutput.txt", ...)

and then wait on the 'CaptureOutput.txt' file and read its' contents.

JBRWilkinson
I am new to MFC can you please give me the syntax of CreateProcess ?? and GetExitProcess ??
Ashish Ashu
Here is the documentation for CreateProcess: http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx You can Google/Bing for examples.
JBRWilkinson