Function WinExecAndWait(Path : Pchar; Visibility : word) : word; var InstanceID : THandle; Msg : TMSg; begin InstanceID := WinExec(Path,Visibility); if InstanceID < 32 then { значение меньше 32 говорит об ошибке Exec } WinExecAndWait := InstanceID else begin Repeat While PeekMessage(Msg,0,0,0,PM_REMOVE) do begin if Msg.Message = WM_QUIT then halt(Msg.wParam); TranslateMessage(Msg); DispatchMessage(Msg); end; until GetModuleUsage(InstanceID) = 0; WinExecAndWait := 32; end; end; |