Kao na primer:
Code:
Var t : longint;
begin
t := GetTickCount;
// Startovanje procesa i cekanje na kraj rada
WinExecAndWait32('c:\program.exe', True);
ShowMessage(Format('Vreme izvrsavanja je %d msec', [GetTickCount-t]));
end;
a kôd metoda za pokretanje i cekanje na proces je (Kôd je preuzet sa news-a, autor je Peter Below):
Code:
function WinExecAndWait32(FileName:String; Visibility : integer):integer;
var { by Pat Ritchey }
zAppName:array[0..512] of char;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(zAppName,FileName);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security
attributes
}
nil, { pointer to thread security attributes
}
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then Result := -1 { pointer to PROCESS_INF }
else
begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,Result);
CloseHandle( ProcessInfo.hProcess );
CloseHandle( ProcessInfo.hThread );
end;
end;