11 messages in net.java.dev.jna.usersRe: [jna-users] jna and comdlg32.dll
FromSent OnAttachments
Marek LewczukFeb 4, 2008 2:36 pm 
Marek LewczukFeb 5, 2008 12:09 am 
Timothy WallFeb 5, 2008 5:52 am 
Marek LewczukFeb 5, 2008 7:13 am 
Timothy WallFeb 5, 2008 7:33 am 
Marek LewczukFeb 5, 2008 7:46 am 
Timothy WallFeb 5, 2008 8:05 am 
Timothy WallFeb 5, 2008 8:09 am 
Marek LewczukFeb 6, 2008 1:13 am 
Timothy WallFeb 6, 2008 5:35 am 
Marek LewczukFeb 6, 2008 6:00 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] jna and comdlg32.dllActions...
From:Marek Lewczuk (mar@lewczuk.com)
Date:Feb 6, 2008 1:13:49 am
List:net.java.dev.jna.users

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