请问这句话的作用是什么?对于_T这个类型不太明白,查过msdn,也没懂。
请大虾解释一下。

解决方案 »

  1.   

    将字符存为Unicode格式。Unicode and MBCS Provide PortabilityWith 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");
      

  2.   

    /* Generic text macros to be used with string literals and character constants.
       Will also allow symbolic constants that resolve to same. */#define _T(x)       __T(x)
    #define _TEXT(x)    __T(x)
      

  3.   

    /* Generic text macros to be used with string literals and character constants.
       Will also allow symbolic constants that resolve to same. */#define _T(x)       __T(x)
    #define _TEXT(x)    __T(x)
      

  4.   

    格式化是一种把其它不是字符串类型的数据转化为CString类型的最常用技巧,比如,把一个整数转化成CString类型,可用如下方法:CString s;
    s.Format(_T("%d"), total);
      字符串使用_T()宏,这是为了代码至少有Unicode的意识,_T()宏在8位字符环境下是如下定义的:#define _T(x) x // 非Unicode版本(non-Unicode version)
    而在Unicode环境下是如下定义的:#define _T(x) L##x // Unicode版本(Unicode version)
    所以在Unicode环境下,它的效果就相当于:s.Format(L"%d", total);