Executeprocess-with command line support
This proc is a Delphi wrapper around und
The Win32 API "CreateProcess". It is
A better idea to use this instead
ShellExecute or other 16-bit functions when you're program is
Run in a 32-bit environment
Procedure executeprocess (filename: string;
Params: string; show: integer );
VaR
Startupinfo: tstartupinfo;
Processinfo: tprocessinformation;
Begin
If Params [1] <> ''then
Params: = ''+ Params;
Fillchar (startupinfo, sizeof (tstartupinfo), 0 );
With startupinfo do
Begin
CB: = sizeof (tstartupinfo );
Dwflags: = startf_useshowwindow;
Wshowwindow: = show;
End;
If not (CreateProcess (pchar (filename), pchar (Params ),
Nil, nil, false, normal_priority_class,
Nil, nil, startupinfo, processinfo ))
Then
Raiselastwin32error;
End;
// Modified version of executeprocess that works
// A command-line parameter
procedure executeprocess (filename,
Params: string;
show: integer);
var
startupinfo: tstartupinfo;
processinfo: tprocessinformation;
begin
Params: = trim (Params);
If Params <> ''then
filename: = filename + ''+ Params;
getstartupinfo (startupinfo);
with startupinfo do begin
CB: = sizeof (tstartupinfo);
dwflags: = startf_useshowwindow;
wshowwindow: = show;
end;
if not (CreateProcess (nil, pchar (filename), nil,
nil, false, normal_priority_class, nil,
nil, startupinfo, processinfo)
then
raiselastwin32error; // from sysutils Unit
end;