GetOpenFileName()存在问题
Problems with GetOpenFileName()
我对以下代码有问题:
HANDLE hFile;
DWORD bytesRead;
OPENFILENAME ofn;
DWORD problem;
WCHAR title[260];
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = (LPWSTR)title;
ofn.nMaxFile = sizeof(title);
ofn.lpstrFilter = TEXT("All files(*.*) *.* ");
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn) == false)
{
problem = CommDlgExtendedError();
return false;
}
从GetOpenFileName,它只需转到problem = CommDlgExtendedError();
,而不显示对话框。
您必须为lpstrFile
结构成员分配内存,并将nMaxFile
设置为其大小。缓冲区的第一个字符也应该设置为