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:Timothy Wall (twal@dev.java.net)
Date:Feb 5, 2008 7:33:17 am
List:net.java.dev.jna.users

On Feb 5, 2008, at 10:13 AM, Marek Lewczuk wrote:

If your structure definition doesn't automatically produce the size you're expecting, you've left something out. Just glancing at the structure def here you've omitted a field after hwndOwner, at the very least.

I fix that too, however it still doesn't work at it should. Dialog is opened as I want with properties that I've send (e.g title or flags), but after file selection struct's lpstrFile is always null. Why ??? After calling struct's toString I've get following result: WindowsComDlg32$OpenFileName(allocated@0xc9307c8 (76 bytes)) { int lStructSize@0=76 Pointer hwndOwner@4=native@0x480636 Pointer hInstance@8=null String lpstrFilter@c=All Files String lpstrCustomFilter@10=null int nMaxCustFilter@14=0 int nFilterIndex@18=1 String lpstrFile@1c=null int nMaxFile@20=0 String lpstrFileTitle@24=null int nMaxFileTitle@28=0 String lpstrInitialDir@2c=null String lpstrTitle@30=dsdsd int Flags@34=524808 short nFileOffset@38=3 short nFileExtension@3a=9 String lpstrDefExt@3c=null Pointer lCustData@40=null Pointer lpfnHook@44=null Pointer lpTemplateName@48=null }

So as you see lpstrFile is null, but nFileOffset and nFileExtension is not. What I'm doing wrong ??? Below fixed code:

The unicode version of the structure uses wchar_t-based strings, which are represented by WString in JNA, unless you define a type converter for String to WString (see W32API.DEFAULT_OPTIONS).

It's easier (and results in a cleaner interface definition) to pass W32API.DEFAULT_OPTIONS to loadLibrary, then you can omit the "-W" suffix from methods and use String for LPTCSTR.