16,472
社区成员
发帖
与我相关
我的任务
分享
void CFileTestDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
//
CFileDialog FileDialog(FALSE, "bmp", NULL, NULL,
"Group Files (*.bmp)|", this);
if (FileDialog.DoModal() == IDCANCEL)
return ;
//得到路径
CString strFilePath = FileDialog.GetPathName();
//打开文件
CFile file;
if(!file.Open(strFilePath, CFile::modeRead))
{
AfxMessageBox("create group file failed,error at CChuangShiMgr::createGroup()");
return;
}
//关闭文件
file.Close();
}
void CFileTestDlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
CFile file;
//随便打个一个文件
if(!file.Open("./config.ini", CFile::modeRead))
{
AfxMessageBox("open failed");
return;
}
//然后关闭
file.Close();
}
BOOL displayerrormessage(void)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL );
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox(0,(LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
return true;
CFile file;
//随便打个一个文件
if(!file.Open("D:\\config.ini", CFile::modeRead))
{
AfxMessageBox("open failed");
return;
}
//然后关闭
file.Close();