![]() |
D5P: ShellExecute soll warten
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 |
Re: D5P: ShellExecute soll warten
Zitat:
|
Re: D5P: ShellExecute soll warten
moin,
versuchs mit folgender Funktion: (Die habe ich übrigens auch irgendwo hier gefunden. Das nächstemal bitte die ![]()
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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:39 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz