Rich Cooper wrote:
> I'm trying to pipe a DOS command to a file using a ShellExecute,
> but it doesn't create  the output file.  Here's the code:
> 
> var D : string;
> ...
>   D := GetStartDir;
>   ShellExecute(0,pChar('ipconfig/all > 
> '),pchar('harbor.txt'),nil,pChar(D),SW_SHOWNORMAL);
> ...
> 
> but no file named 'harbor.txt' gets created.  Does anyone know how to
> fix this?

The issue with "piping" is that it's a function of the "DOS" command 
processor (CMD.EXE under NT/Win2000/XP); ShellExecute on its own knows 
nothing of it.

In order to accomplish what you're describing you'll need to invoke the 
command processor to run the command. Something like:

   ShellExecute(0,
     pchar('OPEN'),
     pchar('c:\windows\system32\cmd.exe'),
     pchar(' /c c:\windows\system32\ipconfig.exe /all > c:\harbor.txt'),
     pchar('c:\'),
     SW_SHOWNORMAL);

ought to do it.

HTH

Stephen Posey
[EMAIL PROTECTED]




This message and its attachments are for the sole use of the intended 
recipient(s) and may contain confidential, 
 proprietary and privileged information. Any unauthorized review, copying, use, 
disclosure or distribution is prohibited. If 
 you are not the intended recipient, please notify the sender immediately by 
replying to the address listed in the From: 
 field and destroy all copies of the original message and its attachments.
_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://www.elists.org/mailman/listinfo/delphi

Reply via email to