我正在使用JNA来使用DLL。
我有一个疑问。
在我之前在library.h中的代码:
NET_DVR_API LONG __stdcall NET_DVR_function_V30(LONG lUserID, LPNET_DVR_CLIENTINFO lpClientInfo, void(CALLBACK *fRealDataCallBack_V30) (LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* pUser) = NULL, void* pUser = NULL, BOOL bBlocked = FALSE);
在使用JNA的java中,我定义了以下内容:
public interface NewFrameCallback extends StdCallCallback {
void invoke(int lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int pUser);
}
int NET_DVR_function_V30(int lUserID, HCNetSDKLibrary.NET_DVR_CLIENTINFO lpClientInfo, HCNetSDKLibrary.NewFrameCallback fakeFuncPointer, Pointer pUser, boolean bBlocked);
并且有效。
现在我收到一个新的dll,我需要使用其他功能:
.h中的定义为:
typedef void (CALLBACK *REALDATACALLBACK) (LONG lPlayHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* pUser);
NET_DVR_API LONG __stdcall NET_DVR_function_V30(LONG lUserID, LPNET_DVR_CLIENTINFO lpClientInfo, void(CALLBACK *fRealDataCallBack_V30) (LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* pUser) = NULL, void* pUser = NULL, BOOL bBlocked = FALSE);
NET_DVR_API LONG __stdcall NET_DVR_function_V40(LONG lUserID, LPNET_DVR_CLIENTINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30 = NULL, void* pUser = NULL)
在java中我只添加:
public interface NewFrameCallback extends StdCallCallback {
void invoke(int lRealHandle, int dwDataType, Pointer pBuffer, int dwBufSize, int pUser);
}
int NET_DVR_function_V30(int lUserID, HCNetSDKLibrary.NET_DVR_CLIENTINFO lpClientInfo, HCNetSDKLibrary.NewFrameCallback fakeFuncPointer, Pointer pUser, boolean bBlocked);
int NET_DVR_function_V40(int lUserID, HCNetSDKLibrary.NET_DVR_CLIENTINFO lpClientInfo, HCNetSDKLibrary.NewFrameCallback fakeFuncPointer, Pointer pUser);
显然它不工作如何在JNA中使用typedef?寻找新的.h REALDATACALLBACK看起来与CALLBACK * fRealDataCallBack_V30相同!