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.

Stats
  • 33
  • 6
  • Can anyone help? – Stats Sep 10 '18 at 20:09
  • Your code contains no enum. Your `SIIGBF` is an interface with a bunch of `static final int` members, which is not the same thing at all -- neither analogous to a Java enum nor to a C or C++ enum. – John Bollinger Sep 14 '18 at 19:06
  • In any case, I don't see much here that we could use to formulate an answer. Our usual expectation is that questions such as this will include a [mcve]. – John Bollinger Sep 14 '18 at 19:10
  • @JohnBollinger As I said above I mapped the entire after this thread https://stackoverflow.com/questions/1157817/how-to-map-enum-in-jna – Stats Sep 14 '18 at 19:43
  • You were right but can you please help me here: https://stackoverflow.com/questions/52348991/jna-invalid-memory-access-unknown-interface – Stats Oct 05 '18 at 19:30

0 Answers0