Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用JAVA中的JNA调用C方法_Java_Jna_Stringbuffer - Fatal编程技术网

无法使用JAVA中的JNA调用C方法

无法使用JAVA中的JNA调用C方法,java,jna,stringbuffer,Java,Jna,Stringbuffer,嗨,我有这个错误,我不知道如何修复 c代码是 extern int APIENTRY LSGetDocData(short hConnect, HWND hWnd, unsigned long *NrDoc, LPSTR FilenameFront, LPSTR FilenameBack

嗨,我有这个错误,我不知道如何修复

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转换为?? 我将永远感激你
提前感谢

还有谁能告诉我如何将LPSTR函数修改为JNANative
long
!=Java
long
。在windows上,本机
long
始终为32位;Java
long
为64位。另请参阅上的常见问题解答(您不使用StringBuffer)。如何解决此问题?我更改字节[]{256}的lpstr。使用
byte[]
/
Native.toString(byte[])
char[]
/
Native.toString(char[])
需要传递缓冲区而不是字符串常量。