This solved my problem :-)
Thanks a lot!
Maarten
----- Original Message ----
From: Timothy Wall <twal...@dev.java.net>
To: use...@jna.dev.java.net
Cc: Maarten Coene <maar...@yahoo.com>
Sent: Tuesday, October 23, 2007 5:16:09 PM
Subject: Re: [jna-users] problem calling user32.SendMessageTimeout
On Oct 23, 2007, at 10:53 AM, Maarten Coene wrote:
I want to do the same in my Java code:
User32 user32 = User32.INSTANCE;
HWND hwnd = new HWND();
hwnd.setPointer(new IntByReference(User32.HWND_BROADCAST));
user32.SendMessageTimeout(hwnd, User32.WM_SETTINGCHANGE, 0,
"Environment", User32.SMTO_ABORTIFHUNG, 5000, 0);
(I took the values for the constants from this site:
http://ghouston.blogspot.com/2005/08/how-to-create-and-change-
environment.html)
However, this doesn't work. I receive error code 1400 (Invalid window
handle).
Can anyone tell me what I'm doing wrong here?
hwnd.setPointer(new IntByReference(User32.HWND_BROADCAST).getPointer
(0));
Otherwise you're using the address of the value rather than the value
itself. Unfortunately, Windows often makes you often want to have a
Pointer(int) constructor. Note that you'll need different type
definitions to work on 64-bit windows.