![]() |
Wrapper-Unit für SHFileOperation
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
Ich möchte hier meine Wrapper-Unit für SHFileOperation vorstellen. Erstmal geht mein Dank an sakura, der den unten genannten Code-Library Eintrag veröffentlich hat und von dem ich auch einige Teile verwendet habe :) Das ganze ist eine Ergänzung zum Code-Library Eintrag ![]() Das ganze ist eine Klasse, die sich TSHFileOperation nennt :) Deklaration
Delphi-Quellcode:
Wie auch bei dem Original SHFileOperation können verschiedene Optionen verwendet werden.
type
TSHFileOperation = class(TObject) private FParentWnd : HWND; FSourceList: TStrings; FTargetList: TStrings; FMappings : Pointer; FSimpleProgressTitle: string; FOperation : TSHFileOperationType; FAPIOperation: UINT; FFlags : TSHFileOperationFlags; FAPIFlags : FILEOP_FLAGS; FAborted : Boolean; FFileOpResult: Integer; procedure SetFlags(AFlags: TSHFileOperationFlags); procedure SetOperation(AOperation: TSHFileOperationType); procedure SetSourceFile(const Value: string); procedure SetTargetFile(const Value: string); function GetSourceFile: string; function GetTargetFile: string; public property ParentWnd: HWND read FParentWnd write FParentWnd; property SourceList: TStrings read FSourceList; property TargetList: TStrings read FTargetList; property SourceFile: string read GetSourceFile write SetSourceFile; property TargetFile: string read GetTargetFile write SetTargetFile; property NameMappings: Pointer read FMappings write FMappings; property SimpleProgressTitle: string read FSimpleProgressTitle write FSimpleProgressTitle; property Flags: TSHFileOperationFlags read FFlags write SetFlags; property Operation: TSHFileOperationType read FOperation write SetOperation; property Aborted: Boolean read FAborted; property FileOpResult: Integer read FFileOpResult; constructor Create(ParentWindow: HWND); destructor Destroy; override; function ExecuteOperation: Integer; procedure Reset; procedure SetOperationByAPI(Operation: UINT); procedure SetFlagsByAPI(Flags: FILEOP_FLAGS); end; Ich habe zusätzlich noch fehlende Konstanten, die in der ShellAPI.pas fehlen, hinzugefügt. Die genaue Bedeutung kann im ![]() Einige Flags stehen möglicherweise nicht in jeder Windows-Version zur Verfügung.
Delphi-Quellcode:
type
TSHFileOperationType = (fotCopy, fotMove, fotDelete, fotRename); TSHFileOperationFlag = (fofMultiDestFiles, fofConfirmMouse, fofSilent, fofRenameOnCollision, fofNoConfirmation, fofWantMappingHandle, fofAllowUndo, fofFilesOnly, fofSimpleProgress, fofNoConfirmMakeDir, fofNoErrorUI, fofNoCopySecurityAttributes, fofNoRecursion, fofNoConnectedElements, fofWantNukeWarning, fofNoRecurseReparse); TSHFileOperationFlags = set of TSHFileOperationFlag;
Die Eigenschaften und Methoden
Als letztes noch ein kleines Anwendungsbeispiel:
Delphi-Quellcode:
Die komplette Unit befindet sich im Anhang, sie ist unter der MPL 1.1 veröffentlicht :)
var
Operation: TSHFileOperation; begin Operation := TSHFileOperation.Create(Self.Handle); try Operation.Operation := fotCopy; Operation.Flags := [fofNoConfirmation, fofFilesOnly]; Operation.SourceList.Assign(Self.SomeSourceList); Operation.TargetList.Assign(Self.SomeTargetList); if Operation.ExecuteOperation <> 0 then ShowMessage('Fehler: ' + IntToStr(Operation.FileOpResult)); finally Operation.Free; end; end; mfG mirage228 [edit=Matze] Mfg, Matze[/edit] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:18 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 by Thomas Breitkreuz