Winapi 如何将JNA接口实现到LPVOID缓冲区?

Winapi 如何将JNA接口实现到LPVOID缓冲区?,winapi,jna,Winapi,Jna,我正在尝试实现一个JNA接口,以从Windows API访问 它具有以下本机签名: BOOL WINAPI VerQueryValue( __in LPCVOID pBlock, __in LPCTSTR lpSubBlock, __out LPVOID *lplpBuffer, __out PUINT puLen ); 我似乎已经成功地转换了其中的三个参数(1-Pointer、2-WString、4-IntByReference),但第三个参数仍然无法实现 什么是

我正在尝试实现一个JNA接口,以从Windows API访问

它具有以下本机签名:

BOOL WINAPI VerQueryValue(
  __in   LPCVOID pBlock,
  __in   LPCTSTR lpSubBlock,
  __out  LPVOID *lplpBuffer,
  __out  PUINT puLen
);
我似乎已经成功地转换了其中的三个参数(1-Pointer、2-WString、4-IntByReference),但第三个参数仍然无法实现


什么是正确的转换,我如何访问存储在该缓冲区中的信息?

我倾向于说正确的映射是:

int VerQueryValue(Pointer pBlock, String lpSubBlock, PointerByReference lplpBuffer, IntByReference puLen);
由于我从未使用过VerQueryValue,下面的代码是关于如何使用结果的猜测:

//other parameters & method calls ...
//empty constructor : VerQueryValue will valuate the pointed value.
PointerByReference lplpBuffer = new PointerByReference();
//empty constructor : VerQueryValue will valuate the pointed value.
IntByReference puLen = new IntByReference ();
int rc = YourClassName.VerQueryValue(pBlock,lpSubBlock,lplpBuffer,puLen);
//Check rc & co
//use the result
byte[] resBytes = lplpBuffer.getValue().getByteArray(0,puLen.getValue());
//if it's a String
String resString = new String(resBytes, ENCODING);

我倾向于说正确的映射是:

int VerQueryValue(Pointer pBlock, String lpSubBlock, PointerByReference lplpBuffer, IntByReference puLen);
由于我从未使用过VerQueryValue,下面的代码是关于如何使用结果的猜测:

//other parameters & method calls ...
//empty constructor : VerQueryValue will valuate the pointed value.
PointerByReference lplpBuffer = new PointerByReference();
//empty constructor : VerQueryValue will valuate the pointed value.
IntByReference puLen = new IntByReference ();
int rc = YourClassName.VerQueryValue(pBlock,lpSubBlock,lplpBuffer,puLen);
//Check rc & co
//use the result
byte[] resBytes = lplpBuffer.getValue().getByteArray(0,puLen.getValue());
//if it's a String
String resString = new String(resBytes, ENCODING);