Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # JNA 메뉴얼에 있는 내용 ```c ////////////////////////////////////////////////////////////////////////// /// <summary> /// 접속 상태 메세지 전송 요청 CALLBACK /// </summary> /// <param name="fStreamHandle"> 접속태 메세지 핸들. </param> /// <param name="pParam">사용자 정의 Param</param> ////////////////////////////////////////////////////////////////////////// EXTERN_C INTEROPLIB_API void W4NVMS_SetCBMessageHandle(LPMESSAGEHANDLER fMessageHandle, LPVOID pParam) ``` void* = LPVOID - [Passing a Java class into a void* parameter with JNA](http://stackoverflow.com/questions/4100990/passing-a-java-class-into-a-void-parameter-with-jna) cpp 샘플소스에서 아래와 같이 넘긴다. ```cpp W4NVMS_SetCBMessageHandle(MessageCallBack, this); ``` ```java myClass myObj = new myClass(); myObj.x = 1; myObj.y = 2; Pointer myPointer = myObj.getPointer(); ``` wireshark 로 패킷 비교   ## JNA 사용 JNA 라이브러리를 사용한다. lib 폴더에 jna-4.2.2.jar 파일을 추가한다.  Java Build Path → Libraries 에서 jar 를 추가한다.  dll을 사용할 인터페이스를 만든다. ```java import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Platform; public interface CHelloWorld extends Library{ CHelloWorld INSTANCE = (CHelloWorld) Native.loadLibrary((Platform.isWindows() ? "com_test_HelloWorld" : "c"), CHelloWorld.class); } ``` main 메소드를 작성한다. ```java public class main { public static void main(String[] args) { CHelloWorld.INSTANCE.print(); } } ``` 실행하면 에러가 발생한다. ``` Unable to load library 'com_test_HelloWorld': Native library (win32-x86/com_test_HelloWorld.dll) not found in resource path ``` bin 폴더에 사용할 dll 파일을 위치한다. 에러 발생 ``` Error looking up function 'print': 지정된 프로시저를 찾을 수 없습니다. ``` open/jna.txt Last modified: 2024/10/05 06:15by 127.0.0.1