dll共享(200)

  • 主题发起人 主题发起人 xiaojun5556
  • 开始时间 开始时间
X

xiaojun5556

Unregistered / Unconfirmed
GUEST, unregistred user!
library Project2;uses SysUtils, Classes, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'main/Unit2.pas';{$R *.res}procedure run_cancel_service(var param:tmy_object);begin myobj:=param; Form1:=tForm1.create(nil); //我在form1show的时候 showmessage(myobj.name);就出错 Form1.showmodal; Form1.free; end;exports run_cancel_service;beginend.主程序procedure TForm1.Button1Click(Sender: TObject);var handle : THandle; run_cancel_service : Trun_cancel_service ; my_object : tmy_object;begin my_object := Tmy_object.Create ; my_object.name := 'aaa'; my_object.pass := '123'; handle:=loadlibrary('Project2.dll'); if handle <> 0 then @run_cancel_service := getprocaddress(handle,'run_cancel_service'); if @run_cancel_service <> nil then run_cancel_service(my_object) ;end;我定义的tmy_object Unit2;interface type tmy_object = class name : string[100]; pass : string[100]; end;帮我改下啊谢谢了当调用的时候出错
 
尽量传递指针,不要传递类型,另外,DLL导出函数约定为stdcall.
 
接受答案了.
 

Similar threads

S
回复
0
查看
700
SUNSTONE的Delphi笔记
S
S
回复
0
查看
694
SUNSTONE的Delphi笔记
S
I
回复
0
查看
782
import
I
后退
顶部