I want to read some functions from a c++ dll in java.
This is a part of the dll code in c++:
typedef void(*E1)(int P1, char * P2);
__declspec(dllimport) void S11(int id, char* P1, E1 callback);
__declspec(dllimport) void Get_P1(int id, char** P1);
And this is the code to read the dll in java:
interface InterestingEvent
{
public void interestingEvent(int id, String P1);
}
class Callback implements InterestingEvent {
@Override
public void interestingEvent(int id, String P1) {
System.out.print("The the event "+ id + " throw this error: " + P1 + "\n");
}
}
public class Main{
public interface Kernel32 extends Library {
public void S11(int id, String P1, InterestingEvent callback);
public void Get_P1(int id, String[] P1);
}
public static void main(String[] args) {
Kernel32 lib = (Kernel32) Native.loadLibrary("path\\to\\dll",
Kernel32.class);
lib.S11(id, "some string", new Callback() );
}
}
And it returns me this error:
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported argument type com.company.Callback at parameter 2 of function S11
what am I doing wrong?
And in the Get_P1 method a value is assigned to the parameter P1 and when return I want it to keep that value, similar to the parameters out in C#. What would be the correct way to invoke this method?
T" if the parameter is aT*. However two or more levels of indirection is not so clear cut. What does thatchar **supposed to denote? What does theGet_P1function look like?