jna指南
配置
引入相关jar
1 | jna.jar |
放置相关so
字段对应
c | java |
---|---|
LONG | NativeLong |
char[] | byte[] |
byte | byte |
byte[] | byte[] |
BOOL | int |
WORD | short or int |
void* | Pointer |
LP** | Pointer |
struct | Structure |
CALLBACK | Callback |
LP**
1 | LP**对应相关去除LP的继承Structure的类的getPointer() |
struct
对应继承Structure的类
NET_**
对应常量
**CallBack
对应回调函数,继承Callback的接口
1 | typedef void(CALLBACK *fLoginResultCallBack)( |
函数
函数对应方法
1 | BOOL NET_DVR_Init() |
string 长度计算
if (wide) {
int len = (string.length() + 1 ) * Native.WCHAR_SIZE;
pointer = new Memory(len);
pointer.setString(0, string, true);
}
else {
byte[] data = Native.toByteArray(string);
pointer = new Memory(data.length + 1);
pointer.write(0, data, 0, data.length);
pointer.setByte(data.length, (byte)0);
}