调用以下函数后,我无法写入任何文件,我尝试过 c++ fstream 和 c 的 fopen 出了什么问题,请帮助提前谢谢我正在使用代码块 mingw windows 7
string openFileDialog(HWND hwnd,char *fileFilter,char *defaultExtension)
{
string fileName = "";
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = fileFilter;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = defaultExtension;
if(GetOpenFileName(&ofn)) {
fileName.assign(szFileName);
}
ZeroMemory(&ofn, sizeof(ofn));
return fileName;
}