I have searched this through stackoverflow and in the internet and haven't found yet an answer.
I have a SDK of a fingerprint reader which I haven't got the source code, meaning I can't change it.
It has a few methods I need to access, which interface I will list below (from RS_API.h):
REALSCANSDK_API int __stdcall RS_InitSDK( const char* configFileName, int option, int* numOfDevice );
REALSCANSDK_API int __stdcall RS_InitDevice( int deviceIndex, int*deviceHandle );
REALSCANSDK_API int __stdcall RS_SetCaptureMode( int deviceHandle, int captureMode, int captureOption, bool withModeLED );
REALSCANSDK_API int __stdcall RS_SetViewWindow( int deviceHandle, HWND windowHandle, RECT drawRectangle, bool autoContrast );
REALSCANSDK_API int __stdcall RS_TakeImageDataEx( int deviceHandle, int timeout, int fingerIndex, bool withLED, unsigned char** imageData, int* imageWidth, int* imageHeight );
I managed to convert all of them to Delphi, but I also wanted to access it from a java app.
My prototype is like this:
public class Leitor {
public native int RS_InitSDK(String configFileName, int option, int numOfDevice );
public static void main(String[] args) {
Leitor leitor= new Leitor();
leitor.RS_InitSDK(null, 0, 0);
}
static
{
System.load("C:\\temp\\SDKSuprema\\SDK\\RS_SDK.dll");
}
}
The load bit works fine (I believe it means that it can find the dll file), but when it runs the native method it throws the exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: leitor.Leitor.RS_InitSDK(Ljava/lang/String;II)I at leitor.Leitor.RS_InitSK(Native Method) at leitor.Leitor.main(Leitor.java:14)
If I rename the dll it changes the error to "Can't load library", so I think the problem is the mapping of the methods.
I also couldn't find how to map a pass by reference parameter to be called from Java. The only solution was by changing the dll to return a structure instead of a single result, but this isn't possible, as I can't change the code.
A second problem will be to send the window handle from swt to the JNI native method...
Any help is greatly welcome!