没有定义UNICODE,所以它里面的字符串就是简单用" "就行了,创建工程的时候包含了UNICODE定义,就必须对TCHAR和char进行转换。
首先是把TCHAR转为char
1 void OpenFileName::TCHAR2Char(const TCHAR* tchar, char * _char) 2 { 3 int iLength; 4 5 iLength = WideCharToMultiByte(CP_ACP, 0, tchar, -1, NULL, 0, NULL, NULL); 6 WideCharToMultiByte(CP_ACP, 0, tchar, -1, _char, iLength, NULL, NULL); 7 }
然后是把char转为TCHAR
1 void OpenFileName::Char2TCHAR(const char * _char, TCHAR * tchar) 2 { 3 int iLength; 4 5 iLength = MultiByteToWideChar(CP_ACP, 0, _char, strlen(_char) + 1, NULL, 0); 6 MultiByteToWideChar(CP_ACP, 0, _char, strlen(_char) + 1, tchar, iLength); 7 }