procedure ShellExecuteWrapper(lpExe: String; lpParameters: String); begin if ShellExecute(0, nil, PChar(lpExe), PChar(lpParameters), nil, SW_SHOW) <= 32 then begin ShowMessage('Failed to launch "' + lpExe + '".'); end; end; procedure CreateProcessWrapper(lpExe: String; lpParameters: String); var startupInfo: TStartupInfo; processInfo: TProcessInformation; begin ZeroMemory(@startupInfo, SizeOf(startupInfo)); with startupInfo do begin cb:= SizeOf(startupInfo); dwFlags:= STARTF_USESHOWWINDOW; wShowWindow:= SW_SHOW; end; if not CreateProcess(nil, PChar(lpExe + ' ' + lpParameters), nil, nil, False, 0, nil, nil, startupInfo, processInfo) then RaiseLastOSError else begin CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); end; end; procedure TForm1.Button1Click(Sender: TObject); var nBeginning: Cardinal; nEnd: Cardinal; begin nBeginning:= GetTickCount; CreateProcessWrapper('notepad.exe', 'toto.txt'); ShowMessage(IntToStr(GetTickCount - nBeginning)); nBeginning:= GetTickCount; ShellExecuteWrapper('notepad.exe', 'toto.txt'); ShowMessage(IntToStr(GetTickCount - nBeginning)); end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question