MSDN上的GetOpenFileName()函数验证

MSDN的 GetOpenFileName()验证时不能显示“打开对话框”,修改OPENFILENAME的成员lpstrFile[0] = '/0'成功

 

OPENFILENAME ofn;       // common dialog box structure
 char szFile[260];       // buffer for file name
 HWND hwnd =NULL;              // owner window
 HANDLE hf;              // file handle

 char strDirectory[100];

 GetCurrentDirectory(100,strDirectory);


 
 // Initialize OPENFILENAME
 ZeroMemory(&ofn, sizeof(OPENFILENAME));
 ofn.lStructSize = sizeof(OPENFILENAME);
 ofn.lpstrFile = szFile;
 ofn.nMaxFile = sizeof(szFile);
 ofn.lpstrFilter = "Dat/0*.dat/0";
 ofn.lpstrFile[0] = '/0';
 ofn.lpstrTitle = "选择文件";
 ofn.lpstrInitialDir = strDirectory;
 ofn.Flags = OFN_EXPLORER;


 if(GetOpenFileName(&ofn));
 {

 }
 

你可能感兴趣的:(File,null,buffer,dialog,structure)