How to access functions of a class inside a dll using Java (JNA)

280 views Asked by At

I am trying to use several functions of class CashDrawer (https://learn.microsoft.com/en-us/uwp/api/Windows.Devices.PointOfService.CashDrawer) that are inside a windows dll called Windows.Devices.PointOfService.dll through Java using JNA, samples are provided here : https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CashDrawer

I tried a simple helloworld using JNA calling msvcrt.dll but here and in all examples I found the function used is directly inside the dll. My problem is that I don't know how to access the functions of CashDrawer in Windows.Devices.PointOfService.

Easy example :

public interface JNAApiInterface extends Library {
    JNAApiInterface INSTANCE = (JNAApiInterface) Native.loadLibrary("msvcrt", JNAApiInterface.class);

    void printf(String format, Object... args);
}

public static void main(String args[]) {
    JNAApiInterface instance = JNAApiInterface.INSTANCE;
    instance.printf("coucou");
}

I would like to open a CashDrawer, for the moment I only can do this :

public interface JNAApiInterface extends Library {
    JNAApiInterface INSTANCE = (JNAApiInterface) Native.loadLibrary("Windows.Devices.PointOfService", JNAApiInterface.class);

    // ???
}

public static void main(String args[]) {
    JNAApiInterface instance = JNAApiInterface.INSTANCE;
    // ???
}

Other option that I didn't succeed would be to generate Java interface for Windows.Devices.PointOfService.dll using JNAerator but I don't know how to do that.

0

There are 0 answers