使用unicode的话
MessageBox会被替换成MessageBoxW 否则是MessageBoxA
多字节字符 英文1个字节,中文2个字节
unicode 英文2字节 中文2字节.
unicode下数据类型转换:
CString转int
CString b="123";
int i;
i=_ttoi(b); //在使用多字符集下 _atoi(array to integer 的缩写)函数是一个好的选择,它也很少会是一个正确的选择。而在使用 Unicode 字符,你应该用_ttoi(),它在 ANSI 编码系统中被编译成_atoi()
int型转CString型
CString a;
int b=20;
a.Format(_T("%d"),b);
CString a;
double b=20.0;
a.Format(_T("%f"),b); //如想取小数点后的某几位 比如小数点后两位(_T(%.2f),b)
CString型转double型
CString strs;
double f;
f=_ttol(strs);
CString型转float型
CString strs;
float flt;
flt = (float)atof((char *)(LPTSTR)(LPCTSTR)strs);