有开发中使用过JNative的朋友吗?因项目开发中需要调用本地库文件下面是库文件定义:__int16 IC_ReadProtection (HANDLE ICDev,__int16 Offset,__int16 len,unsigned char* ProtBuffer)说明:读取IC卡保护位调用:HANDLE ICDev ---- IC_InitComm 函数返回的串口标识符      __int16 Offset ---- 读保护位IC卡起始地址      __int16 Len ---- 数据长度      unsigned char * Databuffer ---- 存放数据的缓冲区      数据值为0表示保护位已置 ,1表示未置保护返回:<0 错误。其绝对值为错误号      =0 读保护位成功举例:IC_ReadProtection(ICDev,0,32,ProtBuffer)      读取地址0~31的保护位数据,ProtBuffer 为0的字节表示对应的字节保护位已置。上面是文档信息,我在进行调用时候,该用哪种JNative类型来代替无符号char型指针呢?unsigned char *下面贴下我写的代码片段:但是运行结果有问题,虚拟机崩溃 可能因为参数传入错误
try{
jnative = new JNative(LIB,"IC_ReadProtection");
Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(4*10));
jnative.setRetVal(Type.INT);
int i = 0;
jnative.setParameter(i++, icdev);
jnative.setParameter(i++, 0);
jnative.setParameter(2, 32);
jnative.setParameter(3, p);
jnative.invoke();

System.out.println(jnative.getRetVal());
System.out.println(p.getAsString());
                            p.dispose();
}catch(Exception e){
e.printStackTrace();
}finally{
if(jnative != null)
try {
jnative.dispose();
} catch (NativeException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
以上代码:第一个参数已经得到 第二个 第三个是自定义 第四个参数是用来保存返回值的缓冲区希望广大CSDNer给与急切的帮助