System Delphi

Title: How to realize drag and drop with the explorer
Question: How to react on the windows message WM_DROPFILES ?
Answer:
type
TForm1 = class(TForm)
Memo_AttachedFiles: TMemo;
procedure FormCreate(Sender: TObject);
private
public
procedure WMDROPFILES (var Msg: TMessage); message WM_DROPFILES;
end;
...
uses
ShellAPI;
procedure TForm1.WMDROPFILES(var Msg: TMessage);
var
i,amount,size: integer;
Filename: PChar;
begin
inherited;
Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, Filename, 255);
for i := 0 to (Amount - 1) do
begin
size := DragQueryFile(Msg.WParam, i , nil, 0) + 1;
Filename:= StrAlloc(size);
DragQueryFile(Msg.WParam,i , Filename, size);
// Filemame contains the attached file(s)
Memo_AttachedFiles.Lines.Add(StrPas(Filename));
StrDispose(Filename);
end;
DragFinish(Msg.WParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Form1.Handle, true);
end;