怎么互换TCHAR 与 LPCSTR;      CString与TCHAR
烦出个点子,谢了先。

解决方案 »

  1.   

    Cast Operators 
    A type cast provides a method for explicit conversion of the type of an object in a specific situation.   Syntaxcast-expression :unary-expression
    ( type-name ) cast-expressionThe compiler treats cast-expression as type type-name after a type cast has been made. Casts can be used to convert objects of any scalar type to or from any other scalar type. Explicit type casts are constrained by the same rules that determine the effects of implicit conversions, discussed in Assignment Conversions. Additional restraints on casts may result from the actual sizes or representation of specific types. See Storage of Basic Types in Chapter 3 for information on actual sizes of integral types. For more information on type casts, see Type-Cast Conversions. 
      

  2.   

    LPCSTR是指向TCHAR的指针,关系如下:
    LPCSTR p;
    TCHAR  a[20];
    p = a;
      

  3.   

    TCHAR 与 LPCSTR
    如果不是UNICODE ,  TCHAR = char, LPCSTR = const char *
    如果是UNICODE , TCHAR = WIDE CHAR, LPCSTR = CONST CHAR *
    可以用 MULTIBYTETOWIDECHAR / WideCharToMultiByte 互相转换.
    TCHAR tc;
    CString str = tc;
    CSTRING支持UNICODE
      

  4.   

    TCHAR *w;
    w = d.GetBuffer(d.GetLength());
      

  5.   

    又错了,应该是:
    TCHAR *w;
    CString d("ssss");
    w = d.GetBuffer(d.GetLength());