4 messages in net.java.dev.jna.usersRe: [jna-users] HELP! The instruction...
FromSent OnAttachments
Lei DingFeb 27, 2008 4:01 am 
Timothy WallFeb 27, 2008 7:57 am 
Lei DingFeb 27, 2008 7:45 pm 
Timothy WallFeb 27, 2008 8: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:Re: [jna-users] HELP! The instruction referenced at .... could not be writtenActions...
From:Timothy Wall (twal@dev.java.net)
Date:Feb 27, 2008 7:57:36 am
List:net.java.dev.jna.users

LPTSTR (pszText) is a pointer, not a character array. You can use String or WString depending on whether you are calling the ascii or unicode version of the function.

I think you're also missing a pointer field after cColumns.

On Feb 27, 2008, at 7:01 AM, Lei Ding wrote:

Hello all! I am a new user of JNA. What I am trying to do is accessing a 3rd party program's user interface through Win32 API. More specifically, read the items of a SysListView32 control in the program(which I don't have access to it's source code). Here's my Java code:

Comctl32.LVITEM item = new Comctl32.LVITEM(); item.iSubItem = 0; user32.SendMessage(l_orderList, Comctl32.LVM_GETITEMTEXT, 0,new byte[256]).intValue();

Yet everytime I run my java program, I got a "The instruction at ... referenced memory at ... could not be written" error from the native application(which I am trying to access) and then the native app crashs. Note: I've no problem with access to this program's other contents, such as GetWindowText to all of it's Edit controls.

I thought there were problems with my method signature, so tried many different kinds but all no luck: public LRESULT SendMessage(HWND hwnd, int msg, WPARAM wparam, LVITEM str);

Here's my definition of LVITEM. Thanks a lot!! public static class LVITEM extends Structure { public int mask; public int iItem; public int iSubItem; public int state; public int stateMask; public byte[] pszText; public int cchTextMax; public int iImage; public Pointer lParam; public int iIndent; public int iGroupId; public int cColumns; // tile view columns public Pointer piColFmt; public int iGroup;

/** * */ public LVITEM() { this.iSubItem = 0; cchTextMax = 200; pszText = new byte[200]; pszText[pszText.length -1] = '\0'; allocateMemory(); } }