主要是使用了GetTempPath 和GetTempFileName 两个系统api
1: CString strTempPath;
2: GetTempPath(MAX_PATH,strTempPath.GetBuffer(MAX_PATH));
3: strTempPath.ReleaseBuffer(-1);
4:
5: //临时文件的命名规则 "三个字母前缀4个十六进制的数字".TMP 即:preuuuu.TMP
6: CString strTempFileName;
7: GetTempFileName(strTempPath,"trs",GetCurrentThreadId(),strTempFileName.GetBuffer(MAX_PATH));
8: strTempFileName.ReleaseBuffer(-1);
9:
10: CFile _file;
11: if( !_file.Open(strTempFileName,CFile::typeBinary|CFile::modeWrite|CFile::modeCreate|CFile::shareDenyWrite) )
12: ASSERT(FALSE);
13:
14: //...
15:
16: _file.Close();