沒有定義UNICODE,所以它裡面的字符串就是簡單用" "就行了,創建工程的時候包含了UNICODE定義,就必須對TCHAR和char進行轉換。
首先是把TCHAR轉為char
//將TCHAR轉為char
//*tchar是TCHAR類型指針,*_char是char類型指針
TcharToChar (const TCHAR * tchar, char * _char)
{
int iLength ;
//獲取字節長度
iLength = WideCharToMultiByte(CP_ACP, 0, tchar, -1, NULL, 0, NULL, NULL);
//將tchar值賦給_char
WideCharToMultiByte(CP_ACP, 0, tchar, -1, _char, iLength, NULL, NULL);
}
然後是把char轉為TCHAR
[cpp] view plaincopyprint?
//同上
CharToTchar (const char * _char, TCHAR * tchar)
{
int iLength ;
iLength = MultiByteToWideChar (CP_ACP, 0, _char, strlen (_char) + 1, NULL, 0) ;
MultiByteToWideChar (CP_ACP, 0, _char, strlen (_char) + 1, tchar, iLength) ;
}