Article View: borland.public.delphi.commandlinetools
Article #346Re: I need to pass a command to DOS
From: Erik Heijnen
Date: Mon, 13 Dec 2004 12:15
Date: Mon, 13 Dec 2004 12:15
74 lines
2694 bytes
2694 bytes
Hello Frans,
below is unit i found some time ago. It executes external-commands and waits
for them to finish.
Regards, Erik
//**************************************************************************
*********************
unit execwait;
interface
uses
Windows, Forms, ShellAPI; // Include SHELLAPI in this "uses" clause
function ExecAppWait(AppName, Params: string): Boolean ;
implementation
{
Execute an external application APPNAME.
Pass optional parameters in PARAMS, separated by spaces.
Wait for completion of the application
Returns FALSE if application failed.
}
function ExecAppWait(AppName, Params: string): Boolean;
var
// Structure containing and receiving info about application to start
ShellExInfo: TShellExecuteInfo;
begin
FillChar(ShellExInfo, SizeOf(ShellExInfo), 0);
with ShellExInfo do begin
cbSize := SizeOf(ShellExInfo);
fMask := see_Mask_NoCloseProcess;
Wnd := Application.Handle;
lpFile := PChar(AppName);
lpParameters := PChar(Params);
nShow := sw_ShowNormal;
end;
Result := ShellExecuteEx(@ShellExInfo);
if Result then begin
while WaitForSingleObject(ShellExInfo.HProcess, 100) = WAIT_TIMEOUT do
begin
Application.ProcessMessages;
if Application.Terminated then Break;
end;
end;
end;
end.
//**************************************************************************
*********************
"Frans van Zyl" <fransv@praxima.co.za> wrote in message
news:41a4b767@newsgroups.borland.com...
> Hi,
>
> I need to pass a command to DOS, but I cannot find the way to do it.
>
> I am currently using Delphi 5
>
> Regards
> - Frans van Zyl (fransv@praxima.co.za)
>
>
Technical Details
Message-ID:
<41bd87bf@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41a4b767@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: ff8f1,9a5ccda12f33e0e0 X-Google-Attributes: gidff8f1,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Erik Heijnen" <eheijnen2@planet.nl> From: "Erik Heijnen" <eheijnen2@planet.nl> Newsgroups: borland.public.delphi.commandlinetools References: <41a4b767@newsgroups.borland.com> Subject: Re: I need to pass a command to DOS Date: Mon, 13 Dec 2004 13:15:06 +0100 Lines: 76 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 62.131.74.3 Message-ID: <41bd87bf@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1102940095 62.131.74.3 (13 Dec 2004 04:14:55 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail