This unit is based upon the well-known and largely used WinExecAndWait function The former
WinexecAndWait function doesn't compile under Delphi 2.0 because the GetModuleUsage function is no longer
supported under Win95.
I have simply updated the previous code so that it works with Delphi 2.0 under Windows 95.
With this function you can call Windows-based applications as well as Dos-based commands.
That is 'c:\myapp\app32.exe' as well as command.com /c del *.bak'.
This new WinexecAndWait32 is intended for Delphi 2.0 Win95 only, it works for me but you use it at
your own risk:
http://www.delphifaq.com/images/e1.gif
http://www.delphifaq.com/images/e2.gif
unit WinExc32;
interface
uses Windows;
function WinExecAndWait32(Path: PChar; Visibility: Word;
Timeout : DWORD): integer;
implementation
function WinExecAndWait32(Path: PChar; Visibility: Word;
Timeout : DWORD): integer;
var
WaitResult : integer;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
iResult : integer;
begin
FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
with StartupInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := visibility;
end;
if CreateProcess(nil,path,nil, nil, False,
NORMAL_PRIORITY_CLASS, nil, nil,
StartupInfo, ProcessInfo) then
begin
WaitResult := WaitForSingleObject(ProcessInfo.hProcess, timeout);
result := WaitResult;
end
else
result:=GetLastError;
end;
end.