• Fuentes

 #490594  por crack81
 
Funcion ShellExecuteWait es una implementacion de la version expuesta en el lenguaje Autoit https://www.autoitscript.com/autoit3/do ... teWait.htm
uses
  SysUtils,windows,shellApi;



function ShellExecuteWait(hWnd:HWND;Operation,Filename,Parameters,Directory:PAnsiChar;ShowCmd:Integer):Cardinal;
var
  ExecuteInfo:TShellExecuteInfoA;
  IsShellOk:LongBool;
begin
  ExecuteInfo.cbSize:=sizeof(TShellExecuteInfoA);
  ExecuteInfo.fMask:=SEE_MASK_NOCLOSEPROCESS;
  ExecuteInfo.Wnd:=hWnd;
  ExecuteInfo.lpVerb:=Operation;
  ExecuteInfo.lpFile:=Filename;
  ExecuteInfo.lpParameters:=Parameters;
  ExecuteInfo.nShow:=ShowCmd;

  IsShellOk:=ShellExecuteEx(@ExecuteInfo);
  if not IsShellOk then
  begin
    Result:=GetLastError;
    Exit;
  end
  else Result:=ExecuteInfo.hInstApp;

  if ExecuteInfo.hProcess<>0 then
    Result:=WaitForSingleObject(ExecuteInfo.hProcess,INFINITE);
end;

begin
  ShellExecuteWait(0,'open','calc.exe',nil,nil,SW_SHOWNORMAL);
  ShellExecuteWait(0,'open','notepad.exe',nil,nil,SW_SHOWNORMAL);
end.