System Delphi

uses ShellApi;
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Form1.Handle, true);
Application.OnMessage := AppMessage;
end;
procedure TForm1.AppMessage(var Msg: Tmsg; var Handled: Boolean);
const
BufferLength : DWORD = 511;
var
DroppedFilename : string;
FileIndex : DWORD;
NumDroppedFiles : DWORD;
pDroppedFilename : array [0..511] of Char;
DroppedFileLength : DWORD;
begin
if Msg.message = WM_DROPFILES then
begin
FileIndex := $FFFFFFFF;
NumDroppedFiles := DragQueryFile(Msg.WParam, FileIndex,
pDroppedFilename, BufferLength);
Memo1.Lines.Clear;
for FileIndex := 0 to (NumDroppedFiles - 1) do
begin
DroppedFileLength := DragQueryFile(Msg.WParam, FileIndex,
pDroppedFilename,
BufferLength);
DroppedFilename := StrPas(pDroppedFilename);
Memo1.Lines.Add(pDroppedFilename);
end;
DragFinish(Msg.WParam);
Handled := true;
end;
end;