delphi调用vb的dll出错,请高手指教
VB写的的dbpapi.dll里有个声明的原型是:
Public Declare Function DBPCreate Lib "dbpapi.dll" (ByVal sips As Long, ByVal susers As Long, ByVal spasss As Long, ByRef wport As Integer, ByVal nsize As Long) As Long
只知道原型,没有相应的DLL源代码。
我在Delphi里写的代码如下:
var
Form1: TForm1;
Function DBPCreate(sips:pchar; susers: pchar; spasss: pchar; var wport:Integer; nsize : integer) : Integer; stdcall external 'dbpapi.dll';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ipaddress:pchar;
username:pchar;
password:pchar;
ipport:Integer;
dwn: Integer;
begin
ipaddress:= '127.0.0.1';
username:= 'admin';
password:= 'admin';
ipport:= 12084;
dwn := DBPCreate(ipaddress,username,password,ipport,1); \\断点执行到这里时候报内存错误
end;
end.
不知道我调用的哪里有问题?请高手指教!
[解决办法]
Public Declare Function DBPCreate Lib "dbpapi.dll" (ByVal sips As Long, ByVal susers As Long, ByVal spasss As Long, ByRef wport As Integer, ByVal nsize As Long) As Long
Function DBPCreate(sips:integer; susers:integer; spasss: integer; var wport:word; nsize : integer) : Integer; stdcall external 'dbpapi.dll';
vb Long->delphi integer;
vb Integer->delphi Word;
[解决办法]
VB:
integer:整形(8位带符号数,范围-32768~~+32767)
long:长整型(32位带符号数,范围-2147483648~~+2147483647)
对应Delphi是:smallInt和integer
Function DBPCreate(sips,susers,spasss,nsize:integer;var wport:smallInt:Integer; stdcall external 'dbpapi.dll';
[解决办法]
VB:
integer:整形(8位带符号数,范围-32768~~+32767)
long:长整型(32位带符号数,范围-2147483648~~+2147483647)
对应Delphi是:smallInt和integer
Function DBPCreate(sips,susers,spasss,nsize:integer;var wport:smallInt):Integer; stdcall external 'dbpapi.dll';