-2

jna関数を使用してwinapiを呼び出しています

public muFunction(){
  Magnification.INSTANCE.MagInitialize();
  RECT desktopRect= new RECT();
  HWND desktop = User32.INSTANCE.GetDesktopWindow();
  User32Extra.INSTANCE.GetWindowRect(desktop, desktopRect);
  HINSTANCE hInstance =Kernel32.INSTANCE.GetModuleHandle(null);

  HWND lsm = User32Extra.INSTANCE.FindWindow(null, "MyWindow");
  HWND hwndMag = User32Extra.INSTANCE.CreateWindowEx(new DWORD(0x00000000L), "Magnifier", "MagnifierWindow", new DWORD(0x40000000L|0x0001L|0x10000000L), desktopRect.left, desktopRect.top, desktopRect.right-desktopRect.left, desktopRect.bottom-desktopRect.top, desktop, null, hInstance, null);
  System.out.println(Native.getLastError()); // return 6 as error
}

倍率 APIコード

public interface Magnification extends StdCallLibrary {

    Magnification INSTANCE = (Magnification) Native.loadLibrary("magnification", Magnification.class,
                                                W32APIOptions.DEFAULT_OPTIONS);

    public Boolean MagInitialize();

    public boolean MagSetWindowFilterList(HWND hwndMag, DWORD dword, int i,
            HWND[] excludeHWNDs);

    public boolean MagSetWindowSource(HWND hwndMag, RECT sourceRect);

}

エラーが発生してERROR_INVALID_HANDLEいます。私のコードの何が問題なのですか。

ありがとう

4

1 に答える 1