

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
11 messages in net.java.dev.jna.usersRe: [jna-users] jna and comdlg32.dll| From | Sent On | Attachments |
|---|---|---|
| Marek Lewczuk | Feb 4, 2008 2:36 pm | |
| Marek Lewczuk | Feb 5, 2008 12:09 am | |
| Timothy Wall | Feb 5, 2008 5:52 am | |
| Marek Lewczuk | Feb 5, 2008 7:13 am | |
| Timothy Wall | Feb 5, 2008 7:33 am | |
| Marek Lewczuk | Feb 5, 2008 7:46 am | |
| Timothy Wall | Feb 5, 2008 8:05 am | |
| Timothy Wall | Feb 5, 2008 8:09 am | |
| Marek Lewczuk | Feb 6, 2008 1:13 am | |
| Timothy Wall | Feb 6, 2008 5:35 am | |
| Marek Lewczuk | Feb 6, 2008 6:00 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread 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.dll | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Feb 6, 2008 5:35:44 am | |
| List: | net.java.dev.jna.users | |
On Feb 6, 2008, at 4:14 AM, Marek Lewczuk wrote:
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 ?
Write a loop with a pointer offset to the current string and do Pointer.getString(offset, true) until you get an empty string. Each time increase offset by the length of the string just read, plus one, multiplied by the value of Native.WCHAR_SIZE.
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 ?
Read the docs. it says you'll get an error if the buffer is too small and returns the length needed as the first two bytes. Presumably you can then call it again without showing the dialog. kind of a crappy API.







