你要连续等待两个PROCESS啊,早说啊,方法是一样的了。没问题。
procedure TForm1.Button1Click(Sender: TObject);
var
proc_info: TProcessInformation;
startinfo: TStartupInfo;
//-----------------------------------------
proc_info1: TProcessInformation;
startinfo1: TStartupInfo;
begin
FillChar(proc_info, sizeof(TProcessInformation), 0);
FillChar(startinfo, sizeof(TStartupInfo), 0);
startinfo.cb := sizeof(TStartupInfo);
//----------------------------------------
FillChar(proc_info1, sizeof(TProcessInformation), 0);
FillChar(startinfo1, sizeof(TStartupInfo), 0);
startinfo1.cb := sizeof(TStartupInfo);
//------------------------------------------
if CreateProcess(nil, 'c:/setup.exe', nil, nil, false, NORMAL_PRIORITY_CLASS, nil, nil, startinfo, proc_info) then
begin
WaitForSingleObject(proc_info.hProcess, INFINITE);
CloseHandle(proc_info.hProcess);
CloseHandle(proc_info.hThread);
//----------------------------------------
FillChar(proc_info1, sizeof(TProcessInformation), 0);
FillChar(startinfo1, sizeof(TStartupInfo), 0);
startinfo1.cb := sizeof(TStartupInfo);
//------------------------------------------
if CreateProcess(nil, 'c:/setup.exe', nil, nil, false, NORMAL_PRIORITY_CLASS, nil, nil, startinfo1, proc_info1) then
begin
WaitForSingleObject(proc_info.hProcess, INFINITE);
CloseHandle(proc_info.hProcess);
CloseHandle(proc_info.hThread);
end;
showmessage('可以了。呵呵');
end
else
begin
Application.MessageBox('不能执行程序! ' + 'application', 'Error', MB_ICONEXCLAMATION);
end;
end;