Click to See Complete Forum and Search --> : How can I catch message displayed on MS-Dos window?
Xiaojian Liu
May 14th, 1999, 12:49 PM
I can execute EXE files, for example java.exe
and javac.exe, whatever,from my application.
I want to do two things (like Kawa IDE):
1. to capture the output of the EXEs
2. to run the EXE without MS-Dos window explicitly
displayed
How can I do that?
Thanks.
Craig Muller
May 14th, 1999, 05:11 PM
You can do it all using CreateProcess(). The down side is it is rather a messy business.
1) To capture the output of a process you must redirect stdout and stderr to the calling process using a pipe. The pipe is setup at the time you launch the process. The tricky bit is capturing the messages as the come back. I used an object which attached itself to the message loop an then read the data. Probably a thread would be better these days. You will need to read up on pipes before venturing into this.
2) When creating the process you want to run you can specify how the window should be displayed. I did this for one application I wrote where the lauched processes needed to be iconified on startup. Check the online help for this function and there are some flags you can set to do this.
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory(&si,sizeof si);
si.cb = sizeof si;
si.lpTitle = NULL;
si.dwFlags = STARTF_USESHOWWINDOW;
switch (eMode)
{
case GUI:
si.wShowWindow = SW_RESTORE;
break;
case CONSOLE:
si.wShowWindow = SW_SHOW;
break;
case REDIRECTED:
si.wShowWindow = SW_SHOWNOACTIVATE | SW_MINIMIZE;
si.dwFlags |= STARTF_USESTDHANDLES;
break;
}
Depending on what eMode was set to CreateProcess() would result a different display.
Hopefully that helps a little....
Xiaojian Liu
May 19th, 1999, 12:12 PM
The article by Matt Brunk, "Redirecting Standard Output to a CEdit Control" may help.
"CodeGuru is a great place where you can meet
fantastic people" - Xiaojian Liu
Xiaojian Liu
May 19th, 1999, 12:13 PM
Thank you very much for your help.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.