WM_CLOSE 消息收到了就表明 Handle 没有问题了<br>写个简单的消息传递 Demo 参考一下<br>1.DLL 工程单元代码<br>library Project2;<br><br>uses<br> Windows, Messages;<br><br>const<br> MY_MSG = WM_USER + 101;<br><br>{$R *.res}<br><br>procedure LoadDLL(const AHandle: Pointer); stdcall;<br>begin<br> PostMessage(THandle(AHandle),MY_MSG,11,22);<br>end;<br><br>exports<br> LoadDLL;<br><br>begin<br><br>end.<br><br>2.主程序代码<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>const<br> MY_MSG = WM_USER + 101;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> procedure MyMsgFunc(var AMsg: TMessage); message MY_MSG;<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>procedure LoadDLL(const AHandle: Pointer); stdcall;external 'Project2.dll';<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> LoadDLL(Pointer(Handle));<br>end;<br><br>procedure TForm1.MyMsgFunc(var AMsg: TMessage);<br>begin<br> ShowMessage(IntToStr(AMsg.WParam) + '|' + IntToStr(AMsg.LParam));<br>end;<br><br>end.