这是VC++ DLL 提供的 .h 文件中接口的内容
extern "C" _declspec(dllexport) unsigned char DataProcess(unsigned char *instr,unsigned char *outstr,
unsigned char strlen,unsigned char position,
unsigned char flag);我在VB DLL模块中定义的接口为:
方式一:
Declare Function DataProcess Lib "BKDLL.dll" (ByVal instr$, ByVal outstr$, ByVal strlen$, ByVal position$, ByVal flag$)
方式二:
Declare Function DataProcess Lib "BKDLL.dll" (ByVal instr As String, ByRef outstr As Byte, ByVal strlen As Integer, ByVal position As Integer, ByVal flag As Integer)在类模块中定义:
方式一:
Dim xm As String * 10
Dim xm1 As String * 10
st = DataProcess(xm, xm1, 10, 50, 0)
方式二:
Dim xm As String * 10
Dim xm2(10) As Byte
st = DataProcess(xm, xm2(0), 10, 50, 0)这个方法是解密方法,输入的数据是密文,输出的数据是明文。
我现在遇到的问题是,输出的数据异常,返回内容为空,我试了上述两种方法,都不能正确获取内容,求教VB高手指点一下,看看是否定义的变量类型有问题,还是什么原因。谢谢

解决方案 »

  1.   

    Declare Function DataProcess Lib "BKDLL.dll" (ByVal instr As String, ByVal outstr As String, ByVal strlen As Integer, ByVal position As Integer, ByVal flag As Integer)
      

  2.   

    我按你的方法试了,输出的结果是空。我试了LONG BYTE STRING三种类型输出都是空,我的输入是STRING会不会是输入参数类型有问题呢,我的输入是STRING 怎么转换成LONG和BYTE呢
      

  3.   

    VC 函数必须声明为 stdcall 才能被 VB 调用,这关系到参数栈的使用规则。