#include <locale.h>
读文件:
// TODO: Add your control notification handler code here
char* old_locale = _strdup( setlocale(LC_CTYPE,NULL) );
setlocale( LC_CTYPE, "chs" );
CStdioFile file;
file.Open( L"testFileDemo.txt",CStdioFile::modeRead);
CString strFamilyName;
file.ReadString(strFamilyName);
setlocale( LC_CTYPE, old_locale );
free( old_locale );
写文件
// TODO: Add your control notification handler code here
setlocale( LC_CTYPE, ("chs"));
CString strFile;
CString strLine;
CStdioFile sf;
strFile = L"testFileDemo.txt";
if(sf.Open(strFile,CFile::modeCreate | CFile::modeReadWrite))
{
sf.WriteString( L"testFileDemo你好呀");
MEMORYSTATUS ms = {0};
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&ms);
strLine.Format(_T("物理内存总数:%dM\t可用物理内存数:%dM\t虚拟内存总数:%dM\t可用虚拟内存数:%dM\t内存占用百分比:%d/%%\n"),
ms.dwTotalPhys/1024/1024,ms.dwAvailPhys/1024/1024,ms.dwTotalVirtual/1024/1024,ms.dwAvailVirtual/1024/1024,ms.dwMemoryLoad);
sf.WriteString(strLine);
sf.Close();
}