unit dropfile;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
// declare our DROPFILES message handler
procedure AcceptFiles( var msg : TMessage );
message WM_DROPFILES;
end;
var
Form1: TForm1;
implementation
uses
// this unit contains certain functions that we'll be using
ShellAPI;
{$R *.DFM}
procedure TForm1.AcceptFiles( var msg : TMessage );
const
cnMaxFileNameLen = 255;
var
i,
nCount : integer;
acFileName : array [0..cnMaxFileNameLen] of char;
begin
// find out how many files we're accepting
nCount := DragQueryFile( msg.WParam,
$FFFFFFFF,
acFileName,
cnMaxFileNameLen );
// query Windows one at a time for the file name
for i := 0 to nCount-1 do
begin
DragQueryFile( msg.WParam, i,
acFileName, cnMaxFileNameLen );
// do your thing with the acFileName
MessageBox( Handle, acFileName, '', MB_OK );
end;
// let Windows know that you're done
DragFinish( msg.WParam );
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// tell Windows that you're accepting drag and drop files
DragAcceptFiles( Handle, True );
//< <<
end;
end.
link:http://www.chami.com/tips/delphi/111196D.html