I am trying to use the general dialog of the GetOpenFileName () dialog to open a dialog and allow the user to select multiple files.
I have the OFN_ALLOWMULTISELECT flag set, as well as the OFN_EXPLORER set, so I get a "new style" file selection window.
When I set up my OPENFILENAME structure, I have ann.lpstrFile pointing to the buffer allocated for storing the results, and ofn.nMaxFile is set to its length.
The problem is that if the user selects so many file names that the buffer overflows, calling GetOpenFileName returns FALSE and then CommDlgExtendedError () returns FNERR_BUFFERTOOSMALL.
This is good for detecting errors, and I could increase the size of the buffer to fix it, but sooner or later the user will select enough files to overflow this buffer.
I saw a note on MSDN that says if the buffer is too small, the first two bytes of the lpstrFile buffer will contain the required size, but the returned size seems too small (maybe this is correct if OFN_ALLOWMULTISELECT is not set). In addition, it will require me to re-open the dialogue!
My other thought was to create a dialog box binding procedure and then determine the size of the file names, when I receive a CDN_SELCHANGE notification message and dynamically allocate a buffer of the required size, but while it will write data to a new buffer, it seems to remember the value of orignal ofn .nMaxFile.
- GetOpenFile ?
, , .
2 :
1) MAX_PATH , ,
2) Unicode- GetOpenFileName. ( UNICODE )