用delphi做的api 用VBA怎么调不了????

mrlining 2002-06-01 10:03:57
我用delphi做了一个api,源码如下:
library test;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,
Classes;
type
TTest = procedure of object;
{$R *.res}
procedure test1(t: ttest);stdcall;export;
begin
t;
end;
exports
test1;
begin
end.

然后用VBA调用,源码如下:
Private Declare Sub test1 Lib "test.dll" (ByVal t As Long)
Private Sub CommandButton1_Click()
Call test1(AddressOf aaa)
end sub

其中aaa为全局过程名
在模块1中
public sub aaa()
msgbox "OK"
end sub

调用成功,但是关闭对话框后出现dll调用约定错误,请问这是怎么回事。是delphi程序的错误,还是我调用的错误,或者是其它的错误,请指教。
...全文
47 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
光明山人 2002-06-04
  • 打赏
  • 举报
回复
可能是这一句:
TTest = procedure of object;

改成:
TTest = procedure;

有"of object"表示是类的方法,其指针长度是八个字节;没有是一般过程指针,只占四个字节。全局的过程应该属于一般过程指针。
mrlining 2002-06-03
  • 打赏
  • 举报
回复
为什么没人回答????

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧