在DLL中函数类型定位字符串指针。

解决方案 »

  1.   

    kathywp 具体点,好吗?(我太笨!)
      

  2.   

    在DLL中封装一个字符串输出函数不可以吗?
      

  3.   

    DLL:中
    EXPORT CHAR* DIS()
    VB:
    Private Declare Function dis Lib "test1.dll" () as string
    啥都没有反回
      

  4.   

    一般不用funtion形式返回,而是把输出也封装字输入中,如下例:
    Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As LongSub GetComputerName_test()
        Dim Name As String, Length As Long
        
        Length = 255
        Name = String(Length, 0)
        GetComputerName Name, Length
        Name = Left(Name, Length)
        MsgBox "此一电脑的名称=" & Name, , "GetComputerName"
    End Sub
      

  5.   

    上面的代码中dis的返回值在VB中
    ByVal 变量=DIS()
    (ByVal 变量)为字符串指针
    变量为字符串
    明白了吧!
      

  6.   

    What is your DLL type? ActiveX DLL or normal DLL
    in ActiveX DLL, it's very simple.
    in normal DLL, your must Convert your string to UNICODE before
    return. use MultiByteToWideChar.
    if you don't like MultiByteToWideChar in C,
    you can also use result = StrConv(buf, vbtoUniCode) in VB
    here is a sample:
    in VB:
    Private Declare Function RevString Lib "MyDLL" Alias "RevString" (ByVal lpBuffer As String, ByRef BufOut, nSizeBuf As Long) As Long   s = "xxx[Chinese]XXX"
       buf = StrConv(s, vbfromUnicode)
       call RevString(buf, sout, 255)
       s =  StrConv(sout, vbtoUnicode)in C:
       __declspec( dllexport ) void RecString(char *, char*, long);
       void RecString(char *, char*, long)
    {
        do something
    }
    in your MAKEFILE
       EXPORTS
         RecString@1