http://zhidao.baidu.com/question/292945651.html
int main(int argc, char* argv[]){TCHAR a[]=_T("ghfh");TCHAR b[1024];wsprintf(b,_T("a=%s\n"),a); _tprintf(_T("%s\n"),b);return 0;}
如果你调用LPCTSTR类型的,都要用_T宏,如果是LPCWSTR的用L。程序里面不要混用char, wchar_t和TCHAR的类型,否则写得不适当很容易出现编译错误。
BSTR 转换成TCHAR *的方法
http://prokuso.com/2006/07/bstr.html
后来找到的真正简单的方法是利用_bstr_t建一个中间变量,然后直接给char*赋值。
BSTR strName;
_bstr_t bstrTName = strName;
TCHAR* szFilePath = bstrTName;
_bstr_t bstrTName = strName;
TCHAR* szFilePath = bstrTName;
CString 转换成TCHAR *的方法:
CString theString( "This is a test" );
LPTSTR lpsz = new TCHAR[theString.GetLength()+1];
_tcscpy(lpsz, theString);
LPTSTR lpsz = new TCHAR[theString.GetLength()+1];
_tcscpy(lpsz, theString);