AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

D5P: ShellExecute soll warten

Ein Thema von Demi · begonnen am 28. Jan 2005 · letzter Beitrag vom 28. Jan 2005
Antwort Antwort
Demi

Registriert seit: 25. Dez 2004
2 Beiträge
 
#1

D5P: ShellExecute soll warten

  Alt 28. Jan 2005, 15:27
Hallo Delphianer,
nachdem ShellExecute ein externes Programm gestartet hat, wird in der Delphi-Anwendung schon die nächste Programmzeile bearbeitete. Gibt es eine Möglichkeit, ShellExecute anzuweisen, so lange zu warten, bis das externe Programm beendet ist?

Ich möchte in der Zeit, wo das externe Programm läuft, die Maus- und Tastatur-Eingaben deaktivieren, auch den Affengriff STRG+ALT+ENTF.

Hättest Du einen Tip oder Hinweis für mich?

Vielen Dank und Gruß Demi
  Mit Zitat antworten Zitat
MathiasSimmack
(Gast)

n/a Beiträge
 
#2

Re: D5P: ShellExecute soll warten

  Alt 28. Jan 2005, 15:32
Zitat von Demi:
nachdem ShellExecute ein externes Programm gestartet hat, wird in der Delphi-Anwendung schon die nächste Programmzeile bearbeitete. Gibt es eine Möglichkeit, ShellExecute anzuweisen, so lange zu warten, bis das externe Programm beendet ist?
[dp]"ShellExecuteAndWait"[/dp], [dp]"RunProcess"[/dp]
  Mit Zitat antworten Zitat
xineohp

Registriert seit: 29. Jan 2004
Ort: Heusenstamm
420 Beiträge
 
Delphi 2005 Professional
 
#3

Re: D5P: ShellExecute soll warten

  Alt 28. Jan 2005, 15:33
moin,

versuchs mit folgender Funktion:
(Die habe ich übrigens auch irgendwo hier gefunden. Das nächstemal bitte die Hier im Forum suchenSuche bemühen!)

Delphi-Quellcode:
uses
  ShellAPI, {Shellexecute}
  Windows, {WaítforSingleObject}
  Forms, {Application.}
  SysUtils; {TSearchRec, Findfirst, etc.}
  
  { Messages,  Variants, Classes, Graphics, Controls,
  Dialogs;   }


function ShellExecuteAndWait(Operation, FileName, Parameter, Directory: string;
  Show: Word; bWait: Boolean): Longint;

implementation

function ShellExecuteAndWait(Operation, FileName, Parameter, Directory: string;
  Show: Word; bWait: Boolean): Longint;
var
  bOK: Boolean;
  Info: TShellExecuteInfo;
{
  ****** Parameters ******
  Operation:

  edit      Launches an editor and opens the document for editing.
  explore    Explores the folder specified by lpFile.
  find      Initiates a search starting from the specified directory.
  open      Opens the file, folder specified by the lpFile parameter.
  print      Prints the document file specified by lpFile.
  properties Displays the file or folder's properties.

  FileName:

  Specifies the name of the file or object on which
  ShellExecuteEx will perform the action specified by the lpVerb parameter.

  Parameter:

  String that contains the application parameters.
  The parameters must be separated by spaces.

  Directory:

  specifies the name of the working directory.
  If this member is not specified, the current directory is used as the working directory.

  Show:

  Flags that specify how an application is to be shown when it is opened.
  It can be one of the SW_ values

  bWait:

  If true, the function waits for the process to terminate
}

begin
  FillChar(Info, SizeOf(Info), Chr(0));
  Info.cbSize := SizeOf(Info);
  Info.fMask := SEE_MASK_NOCLOSEPROCESS;
  Info.lpVerb := PChar(Operation);
  Info.lpFile := PChar(FileName);
  Info.lpParameters := PChar(Parameter);
  Info.lpDirectory := PChar(Directory);
  Info.nShow := Show;
  bOK := Boolean(ShellExecuteEx(@Info));
  if bOK then
  begin
    if bWait then
    begin
      while WaitForSingleObject(Info.hProcess, 100) = WAIT_TIMEOUT
        do Application.ProcessMessages;
      bOK := GetExitCodeProcess(Info.hProcess, DWORD(Result));
    end
    else
      Result := 0;
  end;
  if not bOK then Result := -1;
end;
Peter Enenkel
blubb
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz