

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
11 messages in net.java.dev.jna.users[jna-users] char* versus wchar_t * in...| From | Sent On | Attachments |
|---|---|---|
| Dale...@coats.com | May 13, 2008 5:17 am | |
| Timothy Wall | May 13, 2008 6:00 am | |
| Timothy Wall | May 13, 2008 6:05 am | |
| Dale...@coats.com | May 13, 2008 8:55 am | |
| Timothy Wall | May 13, 2008 9:06 am | |
| Dale...@coats.com | May 13, 2008 11:46 am | .zip |
| Daniel Kaufmann | May 13, 2008 5:16 pm | |
| Dale...@coats.com | May 14, 2008 5:02 am | |
| Timothy Wall | May 14, 2008 6:10 am | |
| Dale...@coats.com | May 15, 2008 6:33 am | |
| Timothy Wall | May 15, 2008 12:38 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread 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 Structure | Actions... |
|---|---|---|
| From: | Dale...@coats.com (Dale...@coats.com) | |
| Date: | May 14, 2008 5:02:01 am | |
| List: | net.java.dev.jna.users | |
On Tue, 13 May 2008 21:16:33 -0300, Daniel Kaufmann wrote:
I believe this is not what Timothy was saying. I think he was saying something like this:
public static class NOTIFYICONDATA extends Structure { public int cbSize; public HANDLE hWnd; public int uID; public int uFlags; public int uCallbackMessage; public HANDLE hIcon; public char[] szTip = new char[64]; }
NOTIFYICONDATA n = NOTIFYICONDATA(); n.szTip[0] = 'T'; n.szTip[1] = 'i'; n.szTip[2] = 'm';
Thanks for the reply. That's "the idea" I was trying to capture in my example. And you're right, it's different than what I had (the ending null and length).
I tried your example, but it continues to exhibit the same issue as my example: the icon does not show.
Of course you can use System.arraycopy to copy from a different array. The important thing is that the array size is 64. Window will know the actual length of the string by looking for a NUL char (In java '\0' or just number 0) In your code you was provided a smaller array so the structure will be smaller than what it should, so if the Windows funtion tries to access there it will get garbage and might even get a segmentation fault.
Good point. I noticed that too, but the way I pasted it here is not really the way I coded it the first time through.
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.
--Dale--
***************************************************
This communication may be confidential and privileged and the views expressed
herein may be personal and are not necessarily the views of Coats plc. It is for
the exclusive use of the intended recipient(s). If you are not the intended
recipient(s), please note that any distribution, copying or use of this
communication or the information in it is strictly prohibited. If you have
received this communication in error, please notify us by email
(Apps...@coats.com) or telephone our technical support helpdesk at Coats
plc. +44 (0)20 8210 5100 (UK 0830H - 1800H, Mon-Fri, GMT) and then delete the
email and any copies of it.
***************************************************








.zip