Results 1 to 2 of 2
- 12-17-2010, 04:35 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 11
- Rep Power
- 0
Using jna for SendMessage Windows call
Hi,
I am trying to use jna for making a win32 API call. I need to SendMessage to a window.
I have a long handle and I am trying to pass it as follows but SendMessage is not returning the correct value. Can someone throw some light on what is wrong with the way I am passing the handle ?
System.out.println("Process ID: " + activeWindow1.getPid());
long handle1 = activeWindow1.getHandle(); // This prints 263948
NativeLong nl = new NativeLong(handle1);
User32 lib = User32.INSTANCE;
NativeLongByReference nlbr = new NativeLongByReference(nl);
long ret1 = lib.SendMessageA(new LongByReference(handle1).getPointer().getPointer(0 ), 32771, 0, 0);
System.out.println("Return value=" + ret1); // This returns 8975925931411506151, expected is 999
long ret2 = lib.SendMessageA(nlbr.getPointer().getPointer(0), 32771, 0, 0);
System.out.println("Return value=" + ret2); //This call also returns 8975925931411506151, expected is 999
}
// This is the standard, stable way of mapping, which supports extensive
// customization and mapping of Java to native types.
public interface User32 extends com.sun.jna.platform.win32.User32 {
User32 INSTANCE = (User32)
Native.loadLibrary("user32",User32.class);
long SendMessageA(Pointer hWnd,int msg,int num1,int num2);
long SendMessageA(PointerType hWnd,int msg,int num1,int num2);
- 01-05-2011, 05:27 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
cross post
https://jna.dev.java.net/servlets/Re...ers&msgNo=4436
It's bad form to post the same question on multiple forums, but I understand why you are doing it since you are not getting any help. From a cursory look at the User32.SendMessageA, it is supposed to return a handle. Handles can change from run to run, so I'm not sure why you expect it to be 999.
Similar Threads
-
call by value and call by reference in java
By sandeepsai39 in forum New To JavaReplies: 7Last Post: 08-12-2010, 11:03 AM -
small windows
By ghostofdarling in forum Java AppletsReplies: 1Last Post: 04-17-2010, 08:55 AM -
Under Windows OS, how to call *.EXE produced in Linux OS?
By tony_lincoln in forum Advanced JavaReplies: 9Last Post: 03-26-2010, 06:08 PM -
how to do a Windows Explorer
By Panchitopro in forum AWT / SwingReplies: 8Last Post: 05-08-2008, 03:31 AM -
swt for windows
By Gajesh Tripathi in forum SWT / JFaceReplies: 2Last Post: 10-18-2007, 06:43 AM


LinkBack URL
About LinkBacks

Bookmarks