Z delphi3000.com:
uses Windows, Messages;
function WinExecAndWait(Path: PChar; Visibility: Word): Word;
var
InstanceID: THandle;
Msg: TMsg;
begin
InstanceID := WinExec(Path, Visibility); //tworzymy proces
if InstanceID < 32 then //wartość PID procesu nie może być mniejsza niż 32
WinExecAndWait := InstanceID
else
repeat
while PeekMessage(Msg, 0, 0, 0, pm_Remove) do //cały czas odbieramy wiadomości
begin
if Msg.Message = WM_QUIT then Halt(Msg.WParam); //jeżeli to WM_QUIT (wyjście, to wychodzimy)
TranslateMessage(Msg); //tłumaczymy i przekazujemy wiadomość
DispatchMessage(Msg);
end;
until GetModuleUsage(InstanceID) = 0; //sprawdzamy czy wciąż moduł działa
WinExecAndWait := 0;
end;
Wystarczy wywołać, a Delphi poczeka, aż się proces zakończy.
Możesz też wywołać normalnie instalkę i przez funkcje w module TlHelp32 (procesy) sprawdzać, czy proces msiexec.exe istnieje.