Timothy Wall pisze:
Since the buffer is within a structure, you will need to define the
field as a Pointer and assign it a sufficiently large Memory block. If
you use a primitive array within a structure, it will be inlined, which
is not what you want here. After the call, you can use
Pointer.getString(0, true) to retrieve the string.
Ok, it almost done, but... GetOpenFileName's structure
(http://msdn2.microsoft.com/en-us/library/ms646839(VS.85).aspx)
allows selection of multiple files - and when many files are chosen,
then lpstrFile contains list of chosen files:
"If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple
files, the buffer contains the current directory followed by the file
names of the selected files. For Explorer-style dialog boxes, the
directory and file name strings are NULL separated, with an extra NULL
character after the last file name. For old-style dialog boxes, the
strings are space separated 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 the user selects only one
file, the lpstrFile string does not have a separator between the path
and file name."
When I do Pointer.getString(0, true) then only directory name path is
returned (e.g. "C:\"), names of chosen files are ignored - I believe
that this has something to do with NULL separator. I'm able to call
Pointer.getCharArray(0, 100) and returned array contains chosen files,
but.... how can I know, how large an array should be in order to get all
chosen files ?
Another question. In order to make it working I had to initialize
struct's field lpstrFile with new Memory(100000000), is there other way
to do it ? How large memory block should be ?
Thanks.
ML