Search code examples
javawinapijna

Invoke Gdi32.GetObject with JNA


I've created a native library mapping for JNA in order to invoke the Gdi32 library's, "GetObject". See: MSDN

My mapping looks like that:

int GetObject(HANDLE hgdiobj, int cbBuffer, Pointer lpvObject);

But this signature seems to be incorrect. An invocation raises this exception:

Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: Error looking up function 'GetObject': The specified procedure couldn't be found.

What's wrong?


Solution

  • The information you need is found in the documentation that you linked to. At the bottom of that document is this:

    DLL                       Gdi32.dll
    Unicode and ANSI names    GetObjectW (Unicode) and GetObjectA (ANSI)
    

    In other words, the function is found in the DLL named Gdi32.dll. And there are two versions, a Unicode version and an ANSI version, with appropriately suffixed names. You are probably trying to bind to a function named GetObject which does not exist.