参考http://www.fwvv.net/info/2006/02/04/20060204-44579.shtmlunit uDragUtils;interfaceuses Windows,ActiveX,Messages;type TMyDragText=class(TObject,IUnknown,IDropTarget) private FHandle:THandle; CanDrop:HResult; FE:TFormatEtc; FRefCount:Integer; protected {IUnknown} function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; function _AddRef: Integer; stdcall; function _Release: Integer; stdcall; {IDropTarget} function DragEnter(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HResult; stdcall; function DragOver(grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HResult; stdcall; function DragLeave: HResult; stdcall; function Drop(const dataObj: IDataObject; grfKeyState: Longint; pt: TPoint; var dwEffect: Longint): HResult; stdcall; public constructor Create(AHandle:THandle); destructor Destroy;override;end;implementation{ TMyDragText }function TMyDragText._AddRef: Integer;begin result:=InterLockedDecrement(FRefCount); if Result=0 then Destroy;end;function TMyDragText._Release: Integer;begin result:=InterLockedIncrement(FRefCount);end;constructor TMyDragText.Create(AHandle:THandle);begin FRefCount:=0; FHandle:=AHandle; RegisterDragDrop(FHandle,self);end;destructor TMyDragText.Destroy;begin RevokeDragDrop(FHandle); inherited;end;function TMyDragText.DragEnter(const dataObj: IDataObject; grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult;begin result:=E_FAIL; CanDrop:=E_FAIL; if Assigned(dataObj) then begin FE.cfFormat:=CF_TEXT; FE.ptd:=nil; FE.dwAspect:=DVASPECT_CONTENT; FE.lindex:=-1; FE.tymed:=TYMED_HGLOBAL; CanDrop:=dataObj.QueryGetData(FE); result:=CanDrop; if not FAILED(result) then dwEffect:=DROPEFFECT_COPY else dwEffect:=DROPEFFECT_NONE; end;end;function TMyDragText.DragLeave: HResult;begin result:=S_OK;end;function TMyDragText.DragOver(grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult;begin result:=S_OK;end;function TMyDragText.Drop(const dataObj: IDataObject; grfKeyState: Integer; pt: TPoint; var dwEffect: Integer): HResult;var medium:stgMedium; hData:HGLOBAL;begin result:=E_FAIL; if not FAILED(CanDrop) then begin result:=dataObj.GetData(FE,medium); hData:=HGLOBAL(GlobalLock(medium.hGlobal)); SendMessage(FHandle,WM_SETTEXT,0,hData); GlobalUnlock(hData); GlobalFree(hData); end;end;function TMyDragText.QueryInterface(const IID: TGUID; out Obj): HResult;begin if GetInterface(IID,Obj) then result:=S_OK else result:=E_NOINTERFACE;end;end.unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,uDragUtils;type TForm1 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private FDragText:TMyDragText; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}uses ActiveX;procedure TForm1.FormCreate(Sender: TObject);begin OleInitialize(nil); FDragText:=TMyDragText.Create(Memo1.Handle);end;procedure TForm1.FormDestroy(Sender: TObject);begin FDragText.Free; OleUninitialize;end;end.