易截截图软件、单文件、免安装、纯绿色、仅160KB

delphi的dll中自定义的类如何在调用程序中实例化?

Delphi(Pascal) code:
unit Unit1;

interface
type
Module=class
published
function ReadTest: integer;
procedure WriteTest(const Value: integer);
published
property Test:integer read ReadTest write WriteTest;
end;
ModuleClass=class of Module;


implementation

{ Module }

function Module.ReadTest: integer;
begin
result:=Test;
end;

procedure Module.WriteTest(const Value: integer);
begin
Test:=value;
end;

end.


Delphi(Pascal) code:
function GetModule():ModuleClass;stdcall;
begin
result:=Module;
end;

上边两个是在dll中定义的.
function GetModule():ModuleClass;far;external 'Project3.dll';
Delphi(Pascal) code:

procedure TForm4.Button1Click(Sender: TObject);
var
m1:ModuleClass;
m:Module;
begin
//

m1:=GetModule();

m:=m1.Create() as Module;
m.Test:=100;
end;

像上边这样行吗?
我实际调用的时候.内存溢出了.好像.不知道咋做!!
学习

我晕.看到有回复.好高兴.但我担心的事还是发生了......



引用
不用 interface 会产生许多麻烦,光一个内存管理就够呛的了,再弄点儿 is/


相关问答:

Python中的Unicode在Delphi如何还原成Gb2312?

已知Python 中:
s = unicode("测试", "gb2312")
s = u'\u6d4b\u8bd5'
print s
测试

在Delphi里面如何将\u6d4b\u8bd5这样的还原成Gb2312的汉字呢?
找到个方法
......

c++builder中如何调用delphi编写的函数?

请问c++builder中如何调用delphi编写的函数?

如在delphi中函数定义为 function a(s1:string, s2:string):string;
那么在c++builder程序中如何定义这一外部函数呢?
直接将pas文件加入工程,编译成功后, ......

delphi连postgresql成功,但不能增加或修改记录

环境winXP,delphi 7, postsgresql 8.4, 已安装odbc for postgresql

连接方式ado -> odbc -> postgresql

Delphi(Pascal) code:

con1.ConnectionString := 'Provider=MSDASQL.1;Extended Pr ......

delphi活该完蛋

一味的追求功能.不注重细节......有很多用不上.总有些莫名其妙的问题.老子以后再也不用了.连个vc6都比不上.跑了两座书城.就几本.还是delphi7的书.还在最下边的角角上.
用多久了?

一天.哈哈^_^.我点烦.发泻一下. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号