如何使用检查类型 char*?(检查填充功能并包含文本> 500个字符或带有文本的内存指针)
我有 my_dll.dll。说明 dll
int my_function(char* param1, struct answer* ans);
#pragma pack(1)
struct answer{
int TType; //IN
unsigned long Amount; //IN
char Rcode [2+1]; //OUT
char AMessage[16 ]; //OUT
int CType; //OUT
char* Check; //OUT
};
在Java中我有代码:
public interface My_Dll extends Library {
public static class answer extends Structure {
public static class ByReference extends answer
implements Structure.ByReference {}
public int TType = 0;
public int Amount = 0;
public byte Rcode[] = new byte[3]; //OUT:
public byte AMessage[] = new byte[16]; //OUT:
public int CType = 0; //OUT:
public ??? Check; //OUT:
protected List getFieldOrder() {
return Arrays.asList(new String[] {"TType", "Amount",
"Rcode","AMessage", "CType","Check"});
}
}
public int my_function(byte track2[], answer.ByReference ans);
}
public static void Start() {
My_Dll test_dll = (My_Dll) Native.loadLibrary("my_dll", My_Dll.class);
My_Dll.answer.ByReference aa = new My_Dll.answer.ByReference();
// In
aa.Amount = 100;
aa.TType =3;
int result = test_dll.my_function(null,aa);
// OUT
System.out.println("Result: " + result);
System.out.println("Rcode: " + new String(aa.Rcode));
System.out.println("Amessage: " + new String(aa.AMessage));
}