5 messages in net.java.dev.jna.usersRe: [jna-users] problem calling user3...
FromSent OnAttachments
Maarten CoeneOct 23, 2007 2:29 am 
Maarten CoeneOct 23, 2007 7:52 am 
Timothy WallOct 23, 2007 8:04 am 
Timothy WallOct 23, 2007 8:15 am 
Maarten CoeneOct 23, 2007 8:40 am 
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] problem calling user32.SendMessageTimeoutActions...
From:Timothy Wall (twal@dev.java.net)
Date:Oct 23, 2007 8:15:46 am
List:net.java.dev.jna.users

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.