

![]() | 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.usersjna 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: | jna and comdlg32.dll | Actions... |
|---|---|---|
| From: | Marek Lewczuk (mar...@lewczuk.com) | |
| Date: | Feb 4, 2008 2:36:28 pm | |
| List: | net.java.dev.jna.users | |
Hi,
I would like to use jna to communicate with comdlg32 on windows. I need to call GetOpenFileNameW() or GetOpenFileNameA(). In order to do that I've create following classes/interfaces:
public interface WindowsComDlg32 extends Library {
public static WindowsComDlg32 INSTANCE = (WindowsComDlg32) Native.loadLibrary("c:\\windows\\system32\\comdlg32.dll", WindowsComDlg32.class);
public static class OpenFileName extends Structure { public int lStructSize = 76; public Pointer hwndOwner; public String lpstrFilter; public String lpstrCustomFilter; public int nMaxCustFilter; public int nFilterIndex; public String lpstrFile; public int nMaxFile; public String lpstrFileTitle; public int nMaxFileTitle; public String lpstrInitialDir; public String lpstrTitle; public int Flags; public short nFileOffset; public short nFileExtension; public String lpstrDefExt; public Pointer lCustData; public Pointer lpfnHook; public Pointer lpTemplateName; @Override public int size () { return 76; }
}
public boolean GetOpenFileNameA (OpenFileName params); public boolean GetOpenFileNameW (OpenFileName params); }
In order to execute I use following code: WindowsComDlg32.OpenFileName params = new WindowsComDlg32.OpenFileName(); params.hwndOwner = Native.getWindowPointer(/*a reference to jframe*/); params.lpstrTitle = "This should be my title"; params.lpstrInitialDir = "c:\\windows"; params.Flags = 512; /* allow multiple files selection */ WindowsComDlg32.INSTANCE.GetOpenFileNameW(params);
Now, it is very strange but sometimes it does work and sometimes not - e.g. I need to unset "params.Flags" in order to open a dialog at all. Even if Flags is 0 it doesn't work properly, cause dialog is opened but the dialog title is not read from params. After selection a file and clicking "OK" the chosen file's path should be stored in lpstrFile but it isn't and sometimes JVM crashes just after making a selection and closing the dialog.
I would be really appreciated for help.
ML







