How to use JNA PostMessage in Java 8

1k views Asked by At

The following code worked in older Java versions, but seems to have quit working in Java 8. Would anyone know why this happened, and how to fix it?

public static String notifyExternalApplication() {
    StringBuffer buf = new StringBuffer("");
    try {
        User32.HWND fusionmsg = User32.INSTANCE.FindWindow("TFusionHdtvTray","HDTV Tray");
        int wmUserPlusOffset = 0x400 + 5014;
        User32.WPARAM two = new User32.WPARAM(2L);
        User32.LPARAM zero = new User32.LPARAM(0L);
        boolean fusResult = User32.INSTANCE.PostMessage(fusionmsg, wmUserPlusOffset, two, zero);
        buf.append(" fusResult was " + fusResult + "\n");
    } catch (RuntimeException e) {
        e.printStackTrace();
        buf.append(" " + e.getMessage());
    } 
    return new String(buf);
}

Edit: When this code runs in all OS's, it returns " fusResult was true". It's just that in the newer Java version, it seems to have no effect.

Edit2: Research done - Ran this same code on the same system, but with different versions of Java. Results posted here. Clarity - The exact code is posted and the result stated. Result if question is answered (usefulness) - Myself, and other coders who use this technique will have an option to get their code working again.

0

There are 0 answers