Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Execute a program from Delphi

404 views
Skip to first unread message

Enrique Martinez Caro

unread,
Nov 26, 1998, 3:00:00 AM11/26/98
to
How can I run an external program (for example NOTEPAD.EXE) from a Delphi
application?

Thanks!

Alex Simonetti

unread,
Nov 26, 1998, 3:00:00 AM11/26/98
to
Any one of the below will do the trick:

CreateProcess
WinExec
ShellExecute

For more info on the calls above, refer to the Win32 SDK help file (included
with Delphi).

Yours,


- - - - - - - - - - - - - - - - - - - - - - -
Alex Simonetti Abreu
Belo Horizonte, MG, Brazil
Check out Resource Explorer --- The best of its kind.
Athena's Home: http://www.bhnet.com.br/~simonet
- - - - - - - - - - - - - - - - - - - - - - -
Enrique Martinez Caro wrote in message <73kktn$dp...@forums.borland.com>...

Philippe Ranger

unread,
Nov 26, 1998, 3:00:00 AM11/26/98
to
Enrique: >>How can I run an external program (for example NOTEPAD.EXE) from
a Delphi
application?
<<

Uses windows;

winExec ('notepad.exe', SW_SHOW);


PhR

Alexandre GUILLIEN

unread,
Nov 28, 1998, 3:00:00 AM11/28/98
to

Philippe Ranger wrote:

I had a few problems with WinExec (slow), so I had to use CreateProcess. Though
complex, I reduced it to a single function so that it can be used easily.
(Note : the result of the function is just there because you can have it ...
otherwise, it does not need to be used.)

uses Windows;

function ExecCommandLine(CommandLine: string): TProcessInformation;

implementation

function ExecCommandLine(CommandLine: string): TProcessInformation;
var StartUpInfos: TStartUpInfo;
begin
StartUpInfos.cb:= SizeOf(StartUpInfos);
StartUpInfos.lpReserved:= nil;
StartUpInfos.lpDesktop:= nil;
StartUpInfos.lpTitle:= nil;
StartUpInfos.dwFlags:= 0;
StartUpInfos.cbReserved2:= 0;
StartUpInfos.lpReserved2:= nil;
CreateProcess(nil, PChar(CommandLine), nil, nil,
False, CREATE_DEFAULT_ERROR_MODE + CREATE_NEW_CONSOLE +
NORMAL_PRIORITY_CLASS,
nil, nil, StartUpInfos, Result);
end;

Alexandre GUILLIEN


0 new messages