如题,VB中的String类型是单字节的字符串,那么用VC定义的WCHAR类型数组,在VB中怎样才能正确地访问到这个数组?如果有API函数或VB中有解决方法就更好了。

解决方案 »

  1.   

    String是单字节的字符串!?谁说的!!Private Sub Command1_Click()
        Dim s As String
        
        s = StrConv("abcd", vbWide)
        MsgBox s
    End Sub
      

  2.   

    VB里的STRING是Unicode字符串类型,是双字节的!
    单字节字符串要用BYTE数组来存放!
      

  3.   

    VB String是双字节的。赋到Byte()就知道了
      

  4.   

    可是,那为什么一个在C中声明的WCHAR型字符串,用VBA读出来的就不对呢?我记得WCHAR也是UNICODE的吧。
    对了,该字符串是从注册表中读出来的二进制串。谢谢大家帮忙!
      

  5.   

    WideChar和Unicode应该可以自动转换的
      

  6.   

    对了,VB中有跟WCHAR相同的字符串类型吗?
    如果有的话用StrConv("abcd", vbUnicode),就可以在VB里通用该字符串了。
      

  7.   

    这是MSDN中对于String类型代码范围的说明:
    The codes for String characters range from 0–255. The first 128 characters (0–127) of the character set correspond to the letters and symbols on a standard U.S. keyboard. These first 128 characters are the same as those defined by the ASCII character set. The second 128 characters (128–255) represent special characters, such as letters in international alphabets, accents, currency symbols, and fractions. The type-declaration character for String is the dollar sign ($).
    也就是说是单字节的,可是我也知道String确实能够表示中文,我都晕了~~
    我只是想从注册表里读出一段二进制串比如:
    49 00 6D 00 61 00 67 00 65 00
    读出来的结果应该是“Image”,这该怎么做啊?