还有就是,与CHAR呢?

解决方案 »

  1.   

    BSTR是字符串,"ABCDEFG\0"之前字符的ascii编码数组。
    CHAR是字符,以上每一个都是一个CHAR
    WCHAR是Wide CHAR就是宽字符,顾名思义,2个CHAR空间保存的字符的Unicode编码。这个编码 没法举例了。不记得~
      

  2.   

    WCHR是wchar_t BSTR是wchar_t*,CHAR是charwchar_t是Unicode用的宽字符类型。用双字表示的字符.汉字字符即为双字可以用Win32Api的MultiByteToWideChar/WideCharToMultiByte或C运行库的mbstowcs/wcstombs系列函数对wchar_t* 和 char* 之间进行转换
      

  3.   

    BSTRs are wide, double-byte (Unicode) strings on 32-bit Windows platforms and narrow, single-byte strings on the Apple® PowerMac™.
    BSTR只能用SysAllocString/SysFreeString来管理,
    wchar_t* 可以通过new/delete来管理。
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp
    BSTR本身保存有string的长度:The length is stored as a 32-bit integer at the memory location preceding the data in the string.
      

  4.   

    还有一个问题:
    TCHAR szBuffer[512];
    wsprintf(szBuffer,_T("errord"));
    SysAllocString(szBuffer);
    最后一行编译通不过.
    error C2664: 'SysAllocString' : cannot convert parameter 1 from 'char [512]' to 'const unsigned short *'