Re: GetOpenFilename()



"DR" <dr1234@xxxxxxxxx> wrote in message
news:e8JPYPnMGHA.3064@xxxxxxxxxxxxxxxxxxxxxxx
What is the recommended way to check if multiple files were selected or
only one after a GetOpenFilename() call? Is there sample code? Basically I
want to get a list of the selected files (with full pathes).

Have you seen this in the help entry for the function?

<quote>
OFN_ALLOWMULTISELECT

Specifies that the File Name list box allows multiple selections. If you
also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user
interface; otherwise, it uses the old-style user interface.
If the user selects more than one file, the lpstrFile buffer returns the
path to the current directory followed by the file names of the selected
files. The nFileOffset member is the offset, in bytes or characters, to the
first file name, and the nFileExtension member is not used. For
Explorer-style dialog boxes, the directory and file name strings are NULL
separated, with an extra NULL character after the last file name. This
format enables the Explorer-style dialog boxes to return long file names
that include spaces. For old-style dialog boxes, the directory and file name
strings are separated by spaces and the function uses short file names for
file names with spaces. You can use the FindFirstFile function to convert
between long and short file names.

If you specify a custom template for an old-style dialog box, the definition
of the File Name list box must contain the LBS_EXTENDEDSEL value
</quote>

If the function succeeds you always have at least one complete path to a
file.

So, here is one way. You determine the first path's length and then add that
advance a pointer that many characters.That brings you to the trailing null
byte. You advance the pointer one character more. If the pointer references
the terminator (0) you are done. If note you advance one character more.

To build a list you could pass through the string once to get the number of
files, then create an array of that many pointers, and pass through the
string a second time inserting the pointers to the first characters of each
of the strings you find into the array.

Regards,
Will



.



Relevant Pages

  • Re: Reading Zip file contents without DLLs... How?
    ... Isn't a PChar just a PString that can only contain ... A PChar points to a single character, but through pointer arithmetic you ... memory containing the strings, and the pointer in the variable that points ...
    (alt.comp.lang.borland-delphi)
  • Re: MFC Interview Tests
    ... Note that in the days of this example, we were still using only 8-bit character strings. ... Surrogate pairs pose a huge number of problems, and by the time we start seriously moving ... pointer pointing to the end of the string. ...
    (microsoft.public.vc.mfc)
  • Re: Search for a string backwards in a file.
    ... default fstreams already read the file into blocks of strings (though the ... when the user reads the last character, ... streambuf's get pointer to the last character, ... Call file.rdbufto get a pointer to the streambuf. ...
    (comp.lang.cpp)
  • Re: Unicode Support
    ... > Not knowing much about UTF-8 (my Unicode knowledge extends as far as ... > literal strings of this form as long as the character code for quote ... > can never appear in a MBCS (multibyte character sequence). ... then XP Notepad directly understands UNICODE and you can ...
    (alt.lang.asm)
  • Re: Need help on string manipulation
    ... better to convert strings to UCS-32 before manipulation? ... Characters represented by wchar_t must use one wchar_t per character, ... which may use a multibyte encoding. ... use some newer Unicode characters, if this is a problem for you, then ...
    (comp.lang.c)