GetOpenFileName: пролемы с инициализацией.
char strFileName[300];
char strPath[300];
OPENFILENAME ofn = { sizeof(OPENFILENAME),
NULL,
NULL,
TEXT("Wave Files\0*.wav\0All Files\0*.*\0\0"),
NULL,
0,
1,
strFileName,
MAX_PATH,
NULL,
0,
strPath,
TEXT("Open Sound File"),
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
0,
0,
TEXT(".wav"),
0,
NULL,
NULL };
GetWindowsDirectory(strPath, MAX_PATH);
bool fl = GetOpenFileName(&ofn);
DWORD dw = CommDlgExtendedError();
в fl false, а в dw 2, то есть CDERR_INITIALIZATION: The common dialog box function failed during initialization. This error often occurs when sufficient memory is not available.
пробовал по-другому:
LPOPENFILENAME pofn;
pofn = new OPENFILENAME;
bool ft = GetOpenFileName(pofn);
dw = CommDlgExtendedError();
то же самое..
не подскажете в чём дело?
может от того, что не передаю хэндл окна(NULL пихаю), но в MSDN написано, что можно и NULL передавать..
Код:
char strFileName[300] = { 0 };
В MSDN написано:
Цитата:
OPENFILENAME::lpstrFile
Long pointer to a buffer that contains a file name used to initialize the File Name edit control.[COLOR=red] The first character of this buffer must be NULL if initialization is not necessary.[/COLOR] When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, file name, and extension of the selected file.
If the buffer is too small, the function returns FALSE. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.
Спасибо, всё заработало.