这是我在ExEx上的回答:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ShlObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
const FileName:string='c:/netlog.txt';
var
DataHandle: THandle;
DataPointer: PDROPFILES;
begin
DataHandle := GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE,SizeOf(DROPFILES)+2+Length(FileName));
DataPointer := PDROPFILES(GlobalLock(DataHandle));
FillChar(DataPointer^,SizeOf(DROPFILES)+2+Length(FileName),0);
DataPointer.pFiles:=SizeOf(DROPFILES);
DataPointer.pt:=Point(0,0);
DataPointer.fNC:=False;
DataPointer.fWide:=False;
Move(FileName[1],Pointer(Integer(DataPointer)+SizeOf(DROPFILES))^,Length(FileName));
GlobalUnlock(DataHandle);
OpenClipboard(Form1.Handle);
EmptyClipboard;
SetClipboardData(CF_HDROP, DataHandle);
CloseClipboard;
end;
end.
shenqw