On Thu, 15 May 2008 15:38:33 -0400, Timothy Wall wrote:
On May 15, 2008, at 9:33 AM, Dale...@coats.com wrote:
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.
The dump_memory showed the contents of the char array was the same,
no matter if I made it with 10 individual chars or if I made it
with the array of 10 chars.
The problem seems to be that the W32HANDLEs are getting wiped-out
when I run the .size() method, but only if I use the char array
and not if I use individual char fields!
The cbSize field is the number of bytes in the structure,
so, perhaps not so brightly, I set the cbSize field _after_
all the other fields are populated, using the .size()
method. I found that if I just moved the population of
cbSize to be first, then I was fine:
NOTIFYICONDATA pnid = new NOTIFYICONDATA();
pnid.cbSize = pnid.size(); // <<<<< GOOD SPOT FOR THIS
pnid.hWnd = hInst;
pnid.uID = 0;
pnid.uFlags = Shell32.NIF_ICON | Shell32.NIF_TIP | Shell32.NIF_MESSAGE;
pnid.uCallbackMessage = Shell32.WM_MOUSEMOVE;
pnid.hIcon = hIcon;
pnid.setSzTip("test t");
// pnid.cbSize = pnid.size(); // Wipes out hWnd & hIcon if szTip is array
Windows works so much better when you give it something other
than null for it's handles!
--Dale--