dll的编译为build with package,調用DLL導出函數建窗體,出現地址錯, 有沒有遇過?怎麽解決?(100分)

  • 主题发起人 主题发起人 hsgrass
  • 开始时间 开始时间
H

hsgrass

Unregistered / Unconfirmed
GUEST, unregistred user!
----------------------unit<br>procedure regplugin();<br>begin<br> &nbsp;TForm2.Create(Application); // tform2 = class(tform); 空白窗體.<br>end;<br><br>exports<br> &nbsp;regplugin;<br>--------------------------------------------------------<br><br>procedure TForm1.btn1Click(Sender: TObject);<br>var<br> &nbsp;h: thandle;<br> &nbsp;p: procedure();<br>begin<br> &nbsp;with dlgOpen1 do<br> &nbsp;begin<br> &nbsp; &nbsp;InitialDir := ExtractFileDir(ParamStr(0));<br> &nbsp; &nbsp;Filter := '*.dll|*.dll';<br> &nbsp; &nbsp;if Execute then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; h := LoadLibrary(pchar(filename));<br> &nbsp; &nbsp; &nbsp; p := GetProcAddress(h, 'regplugin');<br> &nbsp; &nbsp; &nbsp; if assigned(p) then<br> &nbsp; &nbsp; &nbsp; &nbsp; p;<br> &nbsp; &nbsp; &nbsp; FreeLibrary(h); // 釋放出現地址錯.<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;
 
TForm2 没有被释放。
 
TFORM2由APPLICATION负责释放
 
改为使用action作為接口
 
后退
顶部