// ANSI字符串转换为UNICODE字符串 char *pszText = "ANSI字符串转换为UNICODE字符串!"; int cchWideChar = MultiByteToWideChar(CP_ACP, 0, pszText, -1, NULL, 0); PTCHAR ptszText = NULL; ptszText = new TCHAR[cchWideChar]; MultiByteToWideChar(CP_ACP, 0, pszText, -1, ptszText, cchWideChar); MessageBox(ptszText); delete [] ptszText;
// UNICODE字符串转换为ANSI字符串 PTCHAR ptszText = TEXT("UNICODE字符串转换为ANSI字符串!"); int cbMultiByte = WideCharToMultiByte(CP_ACP, 0, ptszText, -1, NULL, 0, NULL, NULL); char *pszText = NULL; pszText = new char[cbMultiByte]; WideCharToMultiByte(CP_ACP, 0, ptszText, -1, pszText, cbMultiByte, NULL, NULL); delete [] pszText;