On May 15, 2008, at 9:33 AM, Dale...@coats.com wrote:
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?
Just include the appropriate header, then do a printf of the value of
sizeof(NOTIFICATIONICONDATA). You can use mingw/cygwin gcc if you
don't have msvc.
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.
You're right, the smallest size should work as long as cbSize is set
correctly.
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.
If you set the system property jna.dump_memory, Structure.toString
will dump the native memory contents as well as individual field values.