On May 14, 2008, at 8:02 AM, Dale...@coats.com wrote:
Here's what I originally had in my code, but simplified
for "forum consumption":
int SZ_TIP_SIZE = 64;
public byte[] szTip = new byte[SZ_TIP_SIZE];
public void setSzTip(String str) {
int len = (str.length() <= SZ_TIP_SIZE ? str.length() :
SZ_TIP_SIZE);
byte[] temp = str.getBytes();
System.arraycopy(temp, 0, szTip, 0, len);
}
Actually, I had a "char" version of the above, that I must have
trashed.
But the above doesn't work, whereas individual char or byte
primitives do work (with or without a null termination character).
I thought maybe the problem was the size() method was returning
the wrong number, but I set that manually and it didn't
improve things.
Does Structure.size() return the same thing as sizeof(NOTIFYICONDATA)
in native code? If not, you may be missing some field definitions.
You should null-terminate any of the szXXX fields, unless you know the
array is already zeroed.
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.