Board index » delphi » STDIN / STDOUT

STDIN / STDOUT

Hi

A have a program (not source) which takes a line from STDIN,
processes it and output an encrypted version of the string to
STDOUT.

I need to call this program within Delphi (using WinExec
preferably) but I'm puzzled as to how I can pass the string to
it via STDIN. Does anyone have any ideas how this could be done?

Please e-mail me!

 

Re:STDIN / STDOUT


Quote
Martin Brooks wrote:
> A have a program (not source) which takes a line from STDIN,
> processes it and output an encrypted version of the string to
> STDOUT.

> I need to call this program within Delphi (using WinExec
> preferably) but I'm puzzled as to how I can pass the string to
> it via STDIN. Does anyone have any ideas how this could be done?

Find an old DOS reference; look up how to redirect stdin to another file
handle.

--

http://www.midnightbeach.com/jon   Personal Pages
http://www.midnightbeach.com/jon/pubs Programming Publications
http://www.midnightbeach.com/hs             Home School Resource List

Re:STDIN / STDOUT


On Thu, 03 Oct 1996 16:06:12 +0100, Martin Brooks

Quote
<mar...@idsukltd.demon.co.uk> wrote:
>Hi

>A have a program (not source) which takes a line from STDIN,
>processes it and output an encrypted version of the string to
>STDOUT.

>I need to call this program within Delphi (using WinExec
>preferably) but I'm puzzled as to how I can pass the string to
>it via STDIN. Does anyone have any ideas how this could be done?

>Please e-mail me!

If you don't want to hassle around with Win32 and CreateProcess, I
think the easiest way is to write the string to a text-file (e.g.
c:\INPUT.TXT') and then create a batch file (e.g. C:\LOADME.BAT') with
the following contents
@echo off
APPTORUN.EXE < c:\INPUT.TXT

you can capture the output via prividing something after >
APPTORUN.EXE < c:\INPUT.TXT > c:\OUTPUT.TXT

don't forget to delete all the files after you are done (and better
don't mess up the root-directory.

Hope this helps
Meikel Weber
m.we...@public.ndh.com
Make sure you visit my homepage
http://ourworld.compuserve.com/Homepages/meikel/mew.htm

Re:STDIN / STDOUT


Martin Brooks <mar...@idsukltd.demon.co.uk> wrote in article
<3253D664.2...@idsukltd.demon.co.uk>...

Quote
> Hi

> A have a program (not source) which takes a line from STDIN,
> processes it and output an encrypted version of the string to
> STDOUT.

> I need to call this program within Delphi (using WinExec
> preferably) but I'm puzzled as to how I can pass the string to
> it via STDIN. Does anyone have any ideas how this could be done?

> Please e-mail me!

Martin,

The easiest way to do it is get help from COMMAND.COM:
Call WinExec with something like this:

WinExec('COMMAND.COM /C ECHO your_input | the_exec.exe > OUTPUT.TXT',
SW_HIDE);

and then read the encrypted version from the OUTPUT.TXT file.

HTH
Peter

Re:STDIN / STDOUT


In article <3253D664.2...@idsukltd.demon.co.uk>,

Quote
Martin Brooks <mar...@idsukltd.demon.co.uk> wrote:
>I need to call this program within Delphi (using WinExec
>preferably) but I'm puzzled as to how I can pass the string to
>it via STDIN. Does anyone have any ideas how this could be done?

CreateProcess is the function you want.
It has a startupinfo parameter which contains:
    HANDLE  hStdInput;
    HANDLE  hStdOutput;
    HANDLE  hStdError;

BTW: I hope we're talking D2 here, because under 16 bit windows there
are no such thing as stdio... ;-)

--
=\                       homepage @ http://www.qsd.no/staff/rune
 *=- R.Moberg, CD-Player Pro info @ http://home.sn.no/home/mobergru/
=/               my own webserver @ http://pumba.qsd.no

Other Threads