delphi调用vb的dll出错,请高手指教

hdwjj 2011-11-26 11:04:40
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.
不知道我调用的哪里有问题?请高手指教!
...全文
71 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hdwjj 2011-11-27
  • 打赏
  • 举报
回复
终于搞定了,虽然回答都不精确,但是还是结贴散分
cqs6616 2011-11-27
  • 打赏
  • 举报
回复
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;
hdwjj 2011-11-27
  • 打赏
  • 举报
回复
自己顶起来
hdwjj 2011-11-27
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 kaikai_kk 的回复:]

VB:
integer:整形(8位带符号数,范围-32768~~+32767)
long:长整型(32位带符号数,范围-2147483648~~+2147483647)

对应Delphi是:smallInt和integer

Function DBPCreate(sips,susers,spasss,nsize:integer;var wport:smallInt):Integer……
[/Quote]

我也想到是这样调用了,但是关键是我想传这些值,如果按照这个函数声明的话,下面变量的值明显不是整型,我怎么传?传内存地址?或者用什么能转换成整型?
ipaddress:= '127.0.0.1';
username:= 'admin';
password:= 'admin';
ipport:= 12084;
kaikai_kk 2011-11-27
  • 打赏
  • 举报
回复
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';
kaikai_kk 2011-11-27
  • 打赏
  • 举报
回复
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';

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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