文件复制/粘贴功能 (200分)

  • 主题发起人 主题发起人 monkey2000
  • 开始时间 开始时间
M

monkey2000

Unregistered / Unconfirmed
GUEST, unregistred user!
如何实现?<br>给个例子
 
现找的,给你!<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp;Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp;StdCtrls,ShlObj;<br><br>type<br>&nbsp;TForm1 = class(TForm)<br>&nbsp; &nbsp;Button1: TButton;<br>&nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br>&nbsp;private<br>&nbsp; &nbsp;{ Private declarations }<br>&nbsp;public<br>&nbsp; &nbsp;{ Public declarations }<br>&nbsp;end;<br><br>var<br>&nbsp;Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>const &nbsp;FileName:string='c:/netlog.txt';<br>var<br>&nbsp;DataHandle: THandle;<br>&nbsp;DataPointer: PDROPFILES;<br>begin<br>&nbsp;DataHandle := GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE,SizeOf(DROPFILES)+2+Length(FileName));<br>&nbsp;DataPointer := PDROPFILES(GlobalLock(DataHandle));<br>&nbsp;FillChar(DataPointer^,SizeOf(DROPFILES)+2+Length(FileName),0);<br><br>&nbsp;DataPointer.pFiles:=SizeOf(DROPFILES);<br>&nbsp;DataPointer.pt:=Point(0,0);<br>&nbsp;DataPointer.fNC:=False;<br>&nbsp;DataPointer.fWide:=False;<br>&nbsp;Move(FileName[1],Pointer(Integer(DataPointer)+SizeOf(DROPFILES))^,Length(FileName));<br>&nbsp;GlobalUnlock(DataHandle);<br>&nbsp;OpenClipboard(Form1.Handle);<br>&nbsp;EmptyClipboard;<br>&nbsp;SetClipboardData(CF_HDROP, DataHandle);<br>&nbsp;CloseClipboard;<br>end;<br><br>end.<br>
 
后退
顶部