1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
var
vSEInfo : TShellExecuteInfo;
begin
//Initialisation de la structure ShellExecuteInfo
ZeroMemory(@vSEInfo, SizeOf(vSEInfo));
//Remplissage de la structure ShellExecuteInfo
vSEInfo.cbSize := SizeOf(vSEInfo);
vSEInfo.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_NO_UI;
vSEInfo.Wnd := vHandle;
vSEInfo.lpVerb := PWideChar(vOperation);
vSEInfo.lpFile := PWideChar(vFichier);
vSEInfo.lpParameters := PWideChar(vParametres);
vSEInfo.lpDirectory := PWideChar(vRepertoire);
vSEInfo.nShow := vAffichage;
ExitCode := 1;
//Execution
if ShellExecuteEx(@vSEInfo) then
begin
//ShellExecuteEx OK : attendre la fin du process
Result := WaitForSingleObject(vSEInfo.hProcess, vDuree);
GetExitCodeProcess(vSEInfo.hProcess, ExitCode);
end
else
begin
//ShellExecuteEx KO : renvoyer l'erreur
Result := GetLastError();
end;
CloseHandle(vSEInfo.hProcess);
end; |
Partager