11 messages in net.java.dev.jna.users[jna-users] char* versus wchar_t * in...
FromSent OnAttachments
Dale...@coats.comMay 13, 2008 5:17 am 
Timothy WallMay 13, 2008 6:00 am 
Timothy WallMay 13, 2008 6:05 am 
Dale...@coats.comMay 13, 2008 8:55 am 
Timothy WallMay 13, 2008 9:06 am 
Dale...@coats.comMay 13, 2008 11:46 am.zip
Daniel KaufmannMay 13, 2008 5:16 pm 
Dale...@coats.comMay 14, 2008 5:02 am 
Timothy WallMay 14, 2008 6:10 am 
Dale...@coats.comMay 15, 2008 6:33 am 
Timothy WallMay 15, 2008 12:38 pm 
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:[jna-users] char* versus wchar_t * in a StructureActions...
From:Dale...@coats.com (Dale@coats.com)
Date:May 15, 2008 6:33:23 am
List:net.java.dev.jna.users

On Wed, 14 May 2008 09:10:45 -0400, Timothy Wall wrote:

You should null-terminate any of the szXXX fields, unless you know the array is already zeroed.

You're right, of course. I got sloppy in my iterative testing.

Also remember that Java objects will be GC'd if you don't keep a reference to them; structures will be freed, and callbacks will become no-ops.

No problem there.

Does Structure.size() return the same thing as sizeof(NOTIFYICONDATA) in native code? If not, you may be missing some field definitions.

I don't know how to check the sizeof(NOTIFICATIONICONDATA). Would I just write a C program that built the structure in the same way I'm trying in JNA, and then call that method? I've calculated it manually and I think it was close, but not exactly what I calculated. Although my calculation was what I suspected was wrong, still, I punched in that value instead of the results of size(), but didn't see improvement.

With respect to "missing some field definitions", I saw that the NOTIFYICONDATA structure, as defined in MSDN, has been growing as the OS's grew. I've been using the smallest set of fields; I don't expect all fields are required or tray icons written for WIN2K, for instance, would blow up on WINXP. As long as the cbSize field is right for the structure, it seems like the OS should be happy with it. But since it wasn't that hard, I tried it with all the fields for WIN2K. It showed the same problem as before. There's one more field for WINXP, but I didn't go there because I didn't know how to map a GUID. I didn't try that hard because I doubt it would make a difference anyway.

Is there a way to dump the exact bytes contained in memory under a structure? Since I've got one that works, and the supposed equivalent one that doesn't, it would be interesting to see just what is different.

--Dale--

NOTIFYICONDATA structure: http://msdn.microsoft.com/en-us/library/bb773352%28VS.85%29.aspx