unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, ShellAPI;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
protected
procedure WMDROPFILES(
var Msg: TMessage);
message WM_DROPFILES;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
DF_NUMBEROFFILES = $FFFFFFFF;
procedure TForm1.WMDROPFILES(
var Msg: TMessage);
var
i,
anzahl,
size: Integer;
Dateiname: PChar;
begin
inherited;
anzahl := DragQueryFile(Msg.WParam, DF_NUMBEROFFILES, Dateiname, 255);
for i := 0
to (anzahl - 1)
do
begin
size := DragQueryFile(Msg.WParam, i,
nil, 0) + 1;
Dateiname := StrAlloc(size);
DragQueryFile(Msg.WParam, i, Dateiname, size);
Listbox1.Items.Add(StrPas(Dateiname));
StrDispose(Dateiname);
end;
DragFinish(Msg.WParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Form1.Handle, true);
end;
end.