0
votes

I have one Win32 console application which will be independent EXE and I have front-end designed in MFC.

I want to get the results of the Win32 application to be shown on my GUI. I searched a lot and found some techniques:

  1. Named pipe
  2. DDE
  3. Shared memory

Are any of these an appropriate solution to my problem? Does anyone know of any other solution(s) that might be easier than those I mentioned?

2
It would be a much better idea to extract the code from the console application and place it into a DLL that can be called easily from the MFC application. - Cody Gray
+1 what Cody says. You don't even need a separate DLL, you can have a single .exe that's a console app and also has Win32 GUI. But, if you really do need a separate process for some other reason: what type of communication do you need, and what direction does it go in? Windows messages might be useful in some cases; very simple for the exe to SendMessage using a custom message or WM_COPYDATA to one of the HWNDs in the MFC app. Which technique is "better" all depends on what you are doing, so you really need to explain your scenario better first:) - BrendanMcK
@BrendanMcK: An exe is either console or GUI app, not both. - Serge Wautier
@Serge-appTranslator: The console vs gui designation is mainly about whether Win32 assigns a console to an exe at startup and whether cmd.exe waits for it to complete or not (and perhaps whether the linker expects main vs WinMain); but otherwise that's it. A "gui" app is free to display no UI at all, or can call AllocConsole and use that. Likewise a "console" app is free to call CreateWindow() and run a message loop and display UI - and use or ignore the console as it pleases. Not necessarily a good end-user experience, but Win32 allows it all the same. - BrendanMcK
True enough but exe's do have either console or GUI affinity. See the /SUBSYSTEM linker flag. Fro mthere on, a GUI app can indeed call AllocConsole and a console app can indeed create a msg loop but both cases have side effects. See for example Visual Studio: devenv.exe is a GUI app. For the cmd line version, there is another executable, which they named devenv.com to keep the same name, using a DOS compatibility hack. - Serge Wautier

2 Answers

1
votes

If the output of the console exe is machine parsable, you can use CreateProcess() with pipes for standard input and output which you then parse and display in your UI.

0
votes

You send also message from one application to another, it's quite simple. Look into WM_COPYDATA

http://msdn.microsoft.com/en-us/library/ms649011%28v=vs.85%29.aspx