-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFileCatching.pas
63 lines (46 loc) · 1.2 KB
/
FileCatching.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
unit FileCatching;
interface
uses ShellApi, Windows;
type
TFileCatcher = class(TObject)
private
fDropHandle: HDROP;
function GetFile(Idx: Integer): string;
function GetFileCount: Integer;
function GetPoint: TPoint;
public
constructor Create(DropHandle: HDROP);
destructor Destroy; override;
property FileCount: Integer read GetFileCount;
property Files[Idx: Integer]: string read GetFile;
property DropPoint: TPoint read GetPoint;
end;
implementation
{ TFileCatcher }
constructor TFileCatcher.Create(DropHandle: HDROP);
begin
inherited Create;
fDropHandle := DropHandle;
end;
destructor TFileCatcher.Destroy;
begin
DragFinish(fDropHandle);
inherited;
end;
function TFileCatcher.GetFile(Idx: Integer): string;
var
FileNameLength: Integer;
begin
FileNameLength := DragQueryFile(fDropHandle, Idx, nil, 0);
SetLength(Result, FileNameLength);
DragQueryFile(fDropHandle, Idx, PChar(Result), FileNameLength + 1);
end;
function TFileCatcher.GetFileCount: Integer;
begin
Result := DragQueryFile(fDropHandle, $FFFFFFFF, nil, 0);
end;
function TFileCatcher.GetPoint: TPoint;
begin
DragQueryPoint(fDropHandle, Result);
end;
end.