Thema: Delphi ShellExecute, and Wait!!

Einzelnen Beitrag anzeigen

jensw_2000
(Gast)

n/a Beiträge
 
#2

Re: ShellExecute, and Wait!!

  Alt 3. Okt 2004, 22:05
Hi,

ich habe mal diese "RunAndWait" Procedure in einem kleinen Projekt verbaut.
Das Programm wurde auf Win98, WinNT, Win2000 und WinXP Rechnern verwendet. Die Procedure lief problemlos ...
Unter Win95 und ME habe ich es leider noch nie testen können.

Eventuell ist das ja was für dich...


Code:
procedure RunAndWaitShell(Executable, Parameter: STRING; ShowParameter: INTEGER);
var
  Info: TShellExecuteInfo;
  pInfo: PShellExecuteInfo;
  exitCode: DWord;
begin
  {Pointer to Info}
  pInfo := @Info;
  {Fill info}
  with Info do
  begin
    cbSize := SizeOf(Info);
    fMask := SEE_MASK_NOCLOSEPROCESS;
    wnd   := application.Handle;
    lpVerb := NIL;
    lpFile := PChar(Executable);
    {Parametros al ejecutable}
    {Executable parameters}
    lpParameters := PChar(Parameter + #0);
    lpDirectory := NIL;
    nShow       := ShowParameter;
    hInstApp    := 0;
  end;
  {Execute}
  ShellExecuteEx(pInfo);

  {Wait to finish}
  repeat
    exitCode := WaitForSingleObject(Info.hProcess, 500);
    Application.ProcessMessages;
  until (exitCode <> WAIT_TIMEOUT);
end;

Gruß,
Jens
  Mit Zitat antworten Zitat