VC:
LPSTR _stdcall WINAPI testb(char *a);LPSTR _stdcall WINAPI testb(char *a)
{
a = "Hello";
return a;
}VB:
Public Declare Function testb Lib "D:\MACAddressTool\Release\MACAddressTool.dll" (ByVal strS As String) As String
Dim aa As String
Dim bb As String
bb = testb(aa)执行结束,aa,bb的值都为空,请帮忙看看是怎么回事,哪里出了问题了,谢谢啦。

解决方案 »

  1.   

    VC的DLL里字符串处理用 BSTR 吧
    免得转来转去
      

  2.   

    很挫VC的char ReadTime[13]   解释为VB的   ReadTime   As   String*13VC的字符串指针以NULL为结尾,不能这么传参
      

  3.   

    VC代码#include <windows.h>BSTR WINAPI TestStringForVB(char * a)
    {
    return SysAllocStringByteLen((LPCTSTR)a,sizeof(a));
    }BOOL WINAPI DllMain(
    HINSTANCE hinstDLL,  // handle to DLL module
    DWORD fdwReason,     // reason for calling function
    LPVOID lpvReserved   // reserved
    )
    {
    return TRUE;
    }VB调用Private Declare Function TestStringForVB Lib "你的DLL文件路径\DLL.dll" (ByVal a As String) As StringPrivate Sub Form_Load()    Dim a As String
        
        a = "你好"
        
        Dim b As String
        
        b = TestStringForVB(a)
        
        MsgBox b
        
    End Sub
      

  4.   

    用VB数组传BYTE(),把C的参数属性改成byte
    dim data as string
    dim i ,j as interge
    j = data.Length            For i = 0 To j
                    bytes(i) = Convert.ToByte(data.Substring(i * 2, 2), 16)
                Next i