11 messages in net.java.dev.jna.userschar* versus wchar_t * in a Structure
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:char* versus wchar_t * in a StructureActions...
From:Dale...@coats.com (Dale@coats.com)
Date:May 13, 2008 5:17:37 am
List:net.java.dev.jna.users

I worked through many theories (ByteBuffer, WString, Structure.ByValue, Pointer, etc) but nothing I've tried got me very far with being able to supply a wchar_t into a Structure. I figure that one of the things I've been trying will work if I just get some more implementation details right.

'x' shows as the "tool tip" if I do this:

public static class NOTIFYICONDATA extends Structure { public int cbSize; public HANDLE hWnd; // HWND.setPointer(aJWindow) keeps XP happy, btw! public int uID; public int uFlags; public int uCallbackMessage; public HANDLE hIcon; public char szTip = 'x'; }

But I need to get a bunch of chars into szTip, though. I'll admit to trying char[] and String, but of course that just displayed the pointer related to those objects.

So how to define the szTip?

I found this, and I think it's getting me pretty close to where I want to go:

On Feb 5, 2008, at 11:06 AM, Timothy Wall wrote:

Since the buffer is within a structure, you will need to define the field as a Pointer and assign it a sufficiently large Memory block. If you use a primitive array within a structure, it will be inlined, which is not what you want here. After the call, you can use Pointer.getString(0, true) to retrieve the string.

I don't want to "get" the String so much as "set" it. So here's what I tried:

pnid.szTip = Pointer.createConstant(64L); pnid.szTip.setString(0, "testing tip");

But I got:

This pointer is opaque: opaque@0x40

This might be waaaay off the mark, I know, but my "theory" when stepping out of the world of Java is lacking, so I've been in novice trial and error mode. I've been trying to absorb some of the related recent Jay Walters discussion, but no breakthroughs on getting wchar_t into my structure.

Any advice as a push in the right direction?

--Dale--