cmd /c mkchrt -C -Dfile,
mkchrt runs perfectly except:
1/ A dos box window appears on the screen (though it is always empty)
2/ I dont get any output captured from program.
Any ideas please??
Colin.
scaddenp wrote in message <8ncbb8$2bf3$1...@news.comnet.co.nz>...
>I send the output from the DOS program to a file, wait on a timer to allow
>the DOS program to complete then read the file back into the DELPHI program.
>
>Colin.
>
>scaddenp wrote in message <8ncbb8$2bf3$1...@news.comnet.co.nz>...
Hi,
First of all, I know nothing about Win2000 or NT, and I am no expert.
Even so, maybe I can point in the right direction because I ran into
the same problem on Win95.
Quoting MS:
Due to implementation differences on the Microsoft Windows 95, Windows
98, and Microsoft Windows NT platforms, programs need an intermediate
Win32 Console Application to successfully redirect the output of
16-bit console based applications (MS-DOS applications and batch
files) on Windows 95 and Windows 98.
unquote (Q190351 and others)
The pipe hangs if you do not have an intermediate Win32 console based
app to run the Dos app from.
Basically, what you need to do is to
1. allocate a console window (AllocConsole) for your dos app.
2. use SetWindowPlacement to hide the console window
3. use CreateProcess to launch the dos app.
4. periodically check for the output in the (hidden) console window,
use ReadConsoleOutputCharacter to read lines from the console window.
StartUpInfo : TStartupInfo;
WinPlacement:TWindowPlacement;
FillChar(StartupInfo,Sizeof(TStartupInfo),#0);
StartupInfo.cb := Sizeof(TStartupInfo);
AllocConsole;
WinPlacement.Length:=sizeOf(TWindowPlacement);
WinPlacement.showCmd:=sw_hide;
SetWindowPlacement(GetForegroundWindow,@WinPlacement);
st := ExtractFilePath(Application.ExeName) + DosApp name and command
line
CreateProcess(nil,PChar(st),nil,nil,FALSE,0,nil,nil,StartupInfo,ProcessInfo);
then use ReadConsoleOutputCharacter(GetStdHandle(Std_Output_Handle),
Readbuffer,80,CoordArray,CharsRead) to read output if you like.
to check if Dos app is done:
if WaitForSingleObject(ProcessInfo.hProcess,0)=WAIT_OBJECT_0 THEN
FreeConsole; { "deletes" the console window }
David Rifkind's excellent Proctest? Please tell me more, where to get
please?
Regards
Johan Smit
http://www.subnormal.com/download/proctest.zip
But it doesnt handle the intermediary console. Thanks very much for that!
>If I instead execute
>
>cmd /c mkchrt -C -Dfile,
>
>mkchrt runs perfectly except:
>1/ A dos box window appears on the screen (though it is always empty)
>2/ I dont get any output captured from program.
>
>Any ideas please??
>
What happens if you run this :
cmd /c mkchrt -C -Dfile >> output.txt
If the file output.txt is filled, you can analyze that. If it's not
working,maybe you can put this line in a batch file.
Smola
--
And, then you read this...
(use "ansmolci@" to reply)
(http://www.katedrala.com/ass}
>What happens if you run this :
>
>cmd /c mkchrt -C -Dfile >> output.txt
>
>If the file output.txt is filled, you can analyze that. If it's not
>working,maybe you can put this line in a batch file.
This is indeed what I did until found out about the intermediary console. It
worked fine except that you got no feedback till the program completed.