我写了个动态库
.h文件内容
#ifndef LIB_H
#define LIB_H
extern "C" char __declspec(dllexport)wordtohex(char strbuf[512],int pos);
#endif 
.cpp文件大概内容
#include <iostream>
#include "lib.h"
using namespace std;
char wordtohex(char strbuf[512],int pos)
{    ……
     ……
     ……
     return result[pos],pos;
}
在VB中写的Function如下
 Declare Function wordtohex Lib "dllpublic.dll" (ByVal strc As String, ByVal pos As Integer) As String调用时的代码如下:
    Dim a, d As Integer
    Dim b, c As String
    
    c = Trim(txtId.Text)
    b = wordtohex(c, a)
信息错误提示为  DLL调用约定出错

解决方案 »

  1.   

    将返回值也写在参数里面,byref 的传送
      

  2.   

    VB中  数组头就是指针  VB处理指针的能力  不敢恭维
      

  3.   

    TO 小橙子   能不能说的具体点,你的意思是不是在DLL函数里加上返回值,然后在VB里把返回值写在参数里。
      

  4.   

    Dim a, d As Integer
    Dim b, c As String
    Dim sTemp As StringsTemp = Trim(txtId.Text)
    '要确保字符串c的长度为512
    c = Left(sTemp, 512) & String((512 - Len(sTemp)), vbNullChar)
    b = wordtohex(c, a)
      

  5.   

    TO 兔子  我的DLL没问题吗?