【发布时间】:2012-03-14 07:44:00
【问题描述】:
是否可以将记录数组传递给 dll (delphi)?
我有一条记录放在一个共享(用于 dll 和主要应用程序)delphi 单元中
TmyRecord = record
tgl : Double;
notes: shortstring;
end
TarrOfMyRecord = array[1..1000] of TmyRecord
在dll中,我有一个函数:
function getNotes(var someRecord: TArrOfMyRecord):boolean; stdcall;
begin
someRecord[1].tgl:= now;
someRecord[1].notes:= 'percobaan';
someRecord[2].tgl:= now + 1;
someRecord[2].notes:= 'percobaan1';
return:= true;
end;
我无法获得 dll 返回的 someRecord 的正确值。
谢谢
更新: 这是我在主要应用中的代码:
interface
function getNotes(var someRecord: TArrOfMyRecord):boolean; stdcall; external 'some.dll'
implementation
procedure somefunction;
var myRecord: TarrOfMyRecord;
i: integer;
begin
if getNotes(myRecord) then
for i:= 1 to 1000 do memo1.lines.add(myRecord[i].notes);
end;
【问题讨论】:
-
显示调用 dll 的代码。另外,您是否知道您当前的方法将 DLL 的所有用户都提交到用 Delphi 编写?你对此满意吗?
-
@DavidHeffernan:是的。我知道这一点,没关系。
-
您的函数定义为 getNotes(var someRecord: TArrOfMyRecord) 但您传递了变量 myRecord: TmyRecord?这是错字吗?
-
请给我们看真实的代码。向我们展示编造的代码并没有帮助。真正的代码编译。这没有。同时展示你如何导入函数。
-
@Justmade: Ups..对不起。我已经修好了。谢谢。