JNA can not pass Integer as Enum in method

1

I have an method here

HRESULT GetImage(
  SIZE    size,
  SIIGBF  flags,
  HBITMAP *phbm
);

which takes SIIGBF as an parameter. SIIGBF is an enum you can see here.

As described in this post I create the enum like this:

public static interface SIIGBF {
        public static final int SIIGBF_RESIZETOFIT = 0x00000000;
        public static final int SIIGBF_BIGGERSIZEOK = 0x00000001;
        public static final int SIIGBF_MEMORYONLY = 0x00000002;
        public static final int SIIGBF_ICONONLY  = 0x00000004;
        public static final int SIIGBF_THUMBNAILONLY  = 0x00000008;
        public static final int SIIGBF_INCACHEONLY  = 0x00000010;
    };

I mapped the method at the top so:

WinNT.HRESULT GetImage(WinUser.SIZE size, int flags, WinDef.HBITMAP phbm) {
        return (WinNT.HRESULT) _invokeNativeObject(3,new Object[]{getPointer(),size,flags,phbm},WinNT.HRESULT.class);
    }

I run the method like this:

WinNT.HRESULT hr = factory.GetImage(size,Shell32Extra.SIIGBF.SIIGBF_RESIZETOFIT,hbitmap);

But it returns an Invalid memory access error and maybe it`s because of the enum that put in as an Integer. Can you please help me.

java
c
enums
jna
asked on Stack Overflow Sep 10, 2018 by Stats • edited Sep 14, 2018 by Stats

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0