void CWriteWnd::OpenFileDialog()
{
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH] = _T("");
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = *this;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
GetOpenFileName(&ofn);
/*if (GetOpenFileName(&ofn))
{
std::vector<wstring> vctString(1, szFile);//保存添加文件的路径
}*/
}
Win32 实现 MFC CFileDialog 对话框,布布扣,bubuko.com
原文:http://www.cnblogs.com/chechen/p/3822356.html