我在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

解决方案 »

  1.   

    补充:
    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);
      

  2.   

    delphi中是动态加载DLL的,对于delphi编制的DLL,没发现错误
      

  3.   

    我目前定义就是read:function(var syscode:PChar;var gas_total:PInteger):Integer但是在执行时将报地址错,分别换成string/widestring/pchar/PWideChar,gastotal分别定义为integer/longint/pinteger/PLongint,报错信息一样实在不知到底是何原因了
      

  4.   

    read:function(var syscode:PChar;var gas_total:PInteger):Integer;stdcall;.....
    怎么4楼发着发着就断了