用delphi做的api 用VBA怎么调不了????
我用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程序的错误,还是我调用的错误,或者是其它的错误,请指教。