Hi,

I'm trying to write a simple application in Java with JNA and NetBeans IDE that will communicate with an USB device in a Windows SO and now I'm not receiving notification from WM_DEVICECHANGE. Could someone help me please?

Here I leave the source code that I'm trying for better understanding:

Java Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


package testUsbDetect;

/**
 *
 * @author Coringa
 */

public class TESTUSBDETECT {

 public interface MyUser32 extends User32 {

    public static final MyUser32 MYINSTANCE = (MyUser32) Native.loadLibrary("user32", MyUser32.class, W32APIOptions.UNICODE_OPTIONS);
    public static final int GWLP_WNDPROC = -4;
    public int SetWindowLong(WinDef.HWND hWnd, int nIndex, Callback callback);
}

        public interface MyWinUser extends WinUser {

    public static final int WM_DEVICECHANGE = 0x0219;
}

  public interface MyListener extends StdCallCallback {

    public LRESULT callback(HWND hWnd, int uMsg, WPARAM uParam, LPARAM lParam);
}

public static MyListener listener = new MyListener()
{
    public LRESULT callback(HWND hWnd, int uMsg, WPARAM uParam, LPARAM lParam)
    {
        if (uMsg == MyWinUser.WM_DEVICECHANGE)
        {
           JOptionPane.showMessageDialog(null, "WM_DEVICECHANGE", "Hi! I'm a usb device!", JOptionPane.INFORMATION_MESSAGE);

            return new LRESULT(1);
        }
        return new LRESULT(0);
    }
};


    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {

            // TODO code application logic here

        HWND hWnd = new HWND();
        final JFrame wnd = new JFrame("Device Change");
        wnd.setVisible(true);
        hWnd.setPointer(Native.getWindowPointer(wnd));
        MyUser32.MYINSTANCE.SetWindowLong(hWnd, MyUser32.GWLP_WNDPROC, listener);

    }
}