无法从JAVA使用JNA调用C方法

时间:2013-08-02 15:53:30

标签: java jna stringbuffer

嗨,我有这个错误,我不知道怎么修复。

c代码是

extern int APIENTRY LSGetDocData(short          hConnect,
                 HWND           hWnd,
                 unsigned long  *NrDoc,
                 LPSTR          FilenameFront,
                 LPSTR          FilenameBack,
                 LPSTR          Reserved1,      // not used must be NULL         LPSTR          Reserved2,      // not used must be NULL         LPHANDLE       *FrontImage,
                 LPHANDLE       *BackImage,
                 LPHANDLE       *Reserved3,     // not used must be NULL         LPHANDLE       *Reserved4,     // not used must be NULL         LPSTR          CodelineSW,
                 LPSTR          CodelineHW,
                 LPSTR          BarCode,
                 LPSTR          CodelinesOptical,
                 short          *DocToRead,
                 long           *NrPrinted,
                 LPVOID         Reserved5,      // not used must be NULL         LPVOID         Reserved6);

我的Java方法是

public int LSGetDocData(short hConnect, int hWnd, long[] NrDoc, String FilenameFront, String FilenameBack, String Reserved1, String Reserved2, int[] FrontImage, int[] RearImage,
            int[] FrontImage2, int[] RearImage2, StringBuffer CodelineSW, StringBuffer CodelineHW, StringBuffer Barcode, StringBuffer CodelinesOptical, short[] DocToRead, long[] NrPrinted,
            int Reserved5, int Reserved6);



public int lSGetDocData(long[] nrDoc, int[] frontImage, int[] rearImage,StringBuffer micrHW, StringBuffer barcode,StringBuffer micrSW,StringBuffer codeLineOptical) {

        return LsApi.call.LSGetDocData(hConnect[0], hWnd, nrDoc, "imageF", "ImageR", null, null, frontImage, rearImage, null, null, micrSW, micrHW, barcode, codeLineOptical, new short[0], new long[0], 0, 0);
    }

错误是

  

java.lang.IllegalArgumentException:不支持的参数类型   函数LSGetDocData

的参数11处的java.lang.StringBuffer

我尝试将StringBuffer转换为String - Char - Pointer - Memory并且应用程序显示此错误

invalid access memory

所以如果有人知道如何将StringBuffer转换为?? 我将永远感激不尽 提前谢谢

0 个答案:

没有答案