USES_CONVERSION;
S=OLE2T(B);
或者用WideCharToMultiByte

解决方案 »

  1.   

    For Example:
    unsigned short a;
    unsigned char b,c;
    b=a/256;   //High
    c=a%256;   //low
      

  2.   

    #include "atlbase.h"
    在函数中
    USES_CONVERSION;
    S=W2A(B);
    (S是胆子节字符串指针,B是双字节字符串指针)
      

  3.   

    好像CString可以自动处理吧?另外,野蛮一点的可以用memcpy()
      

  4.   

    Unicode and MBCS Provide Portability
    With MFC version 3.0 and later, MFC, including CString, is enabled for both Unicode and Multibyte Character Sets (MBCS). This support makes it easier for you to write portable applications that you can build for either Unicode or ANSI characters. To enable this portability, each character in a CString object is of type TCHAR, which is defined as wchar_t if you define the symbol _UNICODE when you build your application, or as char if not. A wchar_t character is 16 bits wide. (Unicode is available only under Windows NT.) MBCS is enabled if you build with the symbol _MBCS defined. MFC itself is built with either the _MBCS symbol (for the NAFX libraries) or the _UNICODE symbol (for the UAFX libraries) defined.Note   The CString examples in this and the accompanying articles on strings show literal strings properly formatted for Unicode portability, using the _T macro, which translates the literal string to the formL"literal string"which the compiler treats as a Unicode string. For example, the following code:CString strName = _T("Name");is translated as a Unicode string if _UNICODE is defined or as an ANSI string if not. For more information, see the article Strings: Unicode and Multibyte Character Set (MBCS) Support. A CString object can store up to INT_MAX (2,147,483,647) characters. The TCHAR data type is used to get or set individual characters inside a CString object. Unlike character arrays, the CString class has a built-in memory allocation capability. This allows CString objects to automatically grow as needed (that is, you don’t have to worry about growing a CString object to fit longer strings).