JNative에서 DLL에 전송되는 배열



//   DLL,         
public voic fnGetMax(int[] arrInt) {

	try
	...
	...

	//   JNative  
	JNative jnative = JNative("test.dll","fnGetMax");

	//        
	Pointer aArrIntInput = new Pointer(MemoryBlockFactory.createMemoryBlock(4 * arrInt.length));

	//      
	for (int i = 0; i < arrInt.length; i++) {
		aArrIntInput.setIntAt(4 * i, arrInt[i]);
	}

	//       
	jnative.setParameter(0, pArrIntInput); //     
	jnative.setParameter(1, arrInt.length); //     

	//       
	jnative.setRetVal(Type.INT);

	//   DLL
	jnative.invoke();

	//      
	int iRet = jnative.getRetValAsInt();
	System.out.println(iRet);

	catch
	...
	...
}

더블의 자리.

//         double
double dParam = 10.23;
...
...
jnative.setParameter(0, Type.DOUBLE, Stirng.valueOf(dParam));
...
jnative.setRetVal(Type.DOUBLE);
...
String dRet = jnative.getRetVal();
System.out.println(dRet);

좋은 웹페이지 즐겨찾기