Как запустить приложение и подождать пока оно отработает 2
procedure TForm1.Button3Click(Sender: TObject);
var
si: STARTUPINFO;
pi: PROCESS_INFORMATION;
cmdline: string;
begin
ZeroMemory(@si,sizeof(si));
si.cb:=SizeOf(si);
cmdline:='c:\command.com';
if not CreateProcess( nil, { No module name (use command line). }
PChar(cmdline), { Command line. }
nil, { Process handle not inheritable. }
nil, { Thread handle not inheritable. }
False, { Set handle inheritance to FALSE. }
0, { No creation flags. }
nil, { Use parent's environment block. }
nil, { Use parent's starting directory. }
si, { Pointer to STARTUPINFO structure. }
pi ) { Pointer to PROCESS_INFORMATION structure. }
then
begin
ShowMessage( 'CreateProcess failed.' );
Exit;
end;
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
ShowMessage('Done !');
end;
|
|