How can I use a DLL with a JNA that does not have an interface

After spending a lot of time learning Python to implement a series of DLL-based functions in Java through Jython, I forgot to read the Jython documentation, and the lack of ctypes support made most of my code useless.

I did not want to use JNI

I am trying to access some functions from pcshll32.dll from private messages using my HLLAPI.

I was able to work with Python with virtually no problems, it was very easy to find a lot of documentation and recipes on the Internet.

Now I accidentally discovered JNA, and I have a lot of problems with it. I can hardly find information about this, especially when I try to access non-standard DLLs.

From what I understand, I need to write pcshll32.class, which will be the interface - like the user class User32.class, which seems to be the interface (or maybe I should call it a proxy ...) for User32. dll

Well, this is what I think it happens after reading this .

So ... How to import an external DLL? Is it possible? Do I need to write an interface / proxy? Are there any samples there?

+2
source share
1 answer

You should do it as follows:

public interface PcShll32 extends StdCallLibrary { //StdCallLibrary is for Windows functions PcShll32 INSTANCE = (PcShll32) Native.loadLibrary( "pcshll32", PcShll32.class, W32APIOptions.DEFAULT_OPTIONS); //Options are for Win32API // your methods } 

Of course you must provide this external library for JNA.

For me, the best explanation is the source code.

+2
source

All Articles