How to accept dragged and dropped files from Windows Explorer
{ WMDropFiles declaration: }
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
{ WMDropFiles code: }
procedure TMainFrm.WMDropFiles(var Msg: TWMDropFiles);
var
i, Count: integer;
FileName: array [0..MAX_PATH] of char;
begin
{ How many files? }
Count := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
{ For each file, retrieve the filename }
for i := 0 to Count - 1 do
begin
DragQueryFile(Msg.Drop, i, FileName, MAX_PATH );
{ Do something with FileName }
{ ... }
end;
{ Let Windows know that we're finished }
DragFinish( Msg.Drop );
end;