Reputation: 591
After spending a lot of time learning Python to implement a series of DLL based function into Java via Jython - I forgot to read Jython's documentation, and the lack of ctypes support rendered most of my code useless.
I didn't want to use JNI
I'm trying to access some functions from a pcshll32.dll, from Personal Communications using its HLLAPI.
I did manage to make it work with Python with almost no problems, it was really easy to find a lot of documentation and recipes on the web.
Now I discovered by accident the JNA, and I'm having a LOT of trouble with it. I can barely find information about it, specially when I'm trying to access non-standard DLLs.
From what I understand I need to write a pcshll32.class that will be the interface - much like the User32.class that seems to be an interface (or maybe I should call this a proxy...) to the User32.dll.
Well, that's what I think it's happening after reading this.
So... How can I import an external DLL? Is it possible? Do I need to write the interface/proxy? Are there any samples out there?
Upvotes: 2
Views: 2013
Reputation: 5989
You should do it like this:
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
Upvotes: 2