vote up 1 vote down star

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!!

flag

71% accept rate
What is the "output" of the .NET application? Is that a command line application writing to standard output? – divo Aug 5 at 10:17
No it is a winform application. Let's suppose it queries database for a particular search critaria and outputs the result. – Ashish Ashu Aug 5 at 10:21
Outputs to what? – JonoW Aug 5 at 10:25
I am just to ask how the exe convey the output.. yes it can be flat file...but what is the best way ?? – Ashish Ashu Aug 5 at 10:30

2 Answers

vote up 2 vote down

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!

link|flag
vote up 1 vote down

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.

link|flag
I am new to MFC can you please give me the syntax of CreateProcess ?? and GetExitProcess ?? – Ashish Ashu Aug 5 at 10:28

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.