delphi调用VB编写的DLL函数

myjavauser 2013-01-12 11:17:14
我在delphi调用VB编写的DLL函数碰到个问题,请各位大侠帮忙看下。
VB本身调用该DLL文件,按以下方式定义
Declare Function read Lib "JNDll.dll" Alias "rrrr" (ByRef syscode$, ByRef gas_total As Long) As Integer
在调用该DLL的VB中使用以下调用
Dim syscode$
Dim gastotal As Long
st As Integer
st = read(syscode, gastotal)
在VB中执行正确。

请教在delphi中该如何定义?
我在delphi中定义函数时,将变量syscode分别定义为string/widestring/pchar/PWideChar,gastotal分别定义为integer/longint/pinteger/PLongint,结果均报错。错误信息:
access violation as oX10002228:write of address 0x0045b2b0
...全文
579 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hsfzxjy 2013-01-13
  • 打赏
  • 举报
回复
read:function(var syscode:PChar
myjavauser 2013-01-13
  • 打赏
  • 举报
回复
补充:DLL是用VC写的
hsfzxjy 2013-01-13
  • 打赏
  • 举报
回复
read:function(var syscode:PChar;var gas_total:PInteger):Integer;stdcall;..... 怎么4楼发着发着就断了
myjavauser 2013-01-13
  • 打赏
  • 举报
回复
我目前定义就是read:function(var syscode:PChar;var gas_total:PInteger):Integer 但是在执行时将报地址错,分别换成string/widestring/pchar/PWideChar,gastotal分别定义为integer/longint/pinteger/PLongint,报错信息一样 实在不知到底是何原因了
myjavauser 2013-01-12
  • 打赏
  • 举报
回复
delphi中是动态加载DLL的,对于delphi编制的DLL,没发现错误
hsfzxjy 2013-01-12
  • 打赏
  • 举报
回复
STDCALL
myjavauser 2013-01-12
  • 打赏
  • 举报
回复
补充: delphi函数定义我是这么定义的 read:function(var syscode:PChar;var gas_total:PInteger):Integer; 调用部分这么写的 H := LoadLibrary(pchar('JNDll.DLL')); read:=GetProcAddress(H, 'rrrr'); errorno:=read(syscode,gas_total);

16,748

社区成员

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

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