typedef struct 指针进入 JNA
typedef struct pointer into JNA
我正在为我的应用程序开发JNA,我对在java中使用typedef结构指针感到困惑。请检查我的代码并指导我。提前谢谢你!
下面是我的 c++ 代码
typedef struct tagHWDeviceInfo
{
USHORT VendorID; // vendor id
USHORT ProductID; // product id
DWORD nXExt; // firmware width
DWORD nYExt; // firmware height
DWORD preesure; // pressure level
DWORD penState; // pen state
}HWDeviceInfo, *PHWDeviceInfo;
和 Java 代码
public class HWDeviceInfo extends Structure{
short VendorID;
short ProductID;
int nXExt; // firmware width
int nYExt; // firmware height
int preesure; // pressure level
int penState;
}
现在我的问题是:在 c++ 代码中*PHWDeviceInfo
是什么意思,如何在我的 java 代码中使用此指针?
JNA 会自动将Structure
实例转换为函数调用中的struct *
,并在结构字段定义中自动转换为struct
。 Structure.getPointer()
为您提供 JNA 将使用的指针。
您可以通过使用 Structure.ByReference
和 Structure.ByValue
接口标记类和/或参数类型来修改此默认行为。
JNA清楚地记录了这一点,正如@areeba-irfan-ullah-khan所指出的那样。
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 在C#中处理C++指针而不使用unsafe的最佳方法
- 为什么使用 "this" 指针调用派生成员函数?
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用指针从C++中的数组中获取最大值
- 助记符和指向成员语法的指针
- 嵌入方指针压缩已禁用
- 数组的指针从不分段故障
- C++ 指针的内存地址和指向数组的内存地址如何相同?
- 何时在引用或唯一指针上使用移动语义
- QMetaObject invokeMethod的基于函数指针的语法
- 如何从 std::atomic 中提取指针 T<T>?
- 如何处理JNA中的不透明指针
- JNA:指向字符**的指针
- JNA(Java):如何将指针数组传递给结构
- 如何在 JNA 中获取字节数组作为从 C 字节指针返回的返回
- JNA 本机函数调用和具有双**指针/数组内存分配的结构
- typedef struct 指针进入 JNA
- 用qt返回指向指针jna的对象
- JNA指针到指针