带指针的 PInvoke - C++到 C#
以下是我试图将其转换为 C# 的 C++ 中的 PInvoke 块:
typedef PVOID JHANDLE ;
typedef UINT32 JRET ;
#define JEXPORT __declspec(dllimport) JRET
JEXPORT
JInitialize (
OUT JHANDLE* ppHandle,
IN PVOID context,
IN UINT32 flags
) ;
我尝试了以下调用,但它引发了 PInvokeStackImbalance 异常,指出签名不匹配:
[DllImport("jhi.dll")]
public static extern UInt32 JHI_Initialize(out IntPtr ppHandle, IntPtr context, UInt32 flags);
显然,指针的指针的处理方式不同,但是我不太确定它是如何翻译的。
The following is a PInvoke block in C++ that I'm trying to convert to C#:
typedef PVOID JHANDLE ;
typedef UINT32 JRET ;
#define JEXPORT __declspec(dllimport) JRET
JEXPORT
JInitialize (
OUT JHANDLE* ppHandle,
IN PVOID context,
IN UINT32 flags
) ;
I tried the following call, but it threw a PInvokeStackImbalance exception saying that the signatures don't match:
[DllImport("jhi.dll")]
public static extern UInt32 JHI_Initialize(out IntPtr ppHandle, IntPtr context, UInt32 flags);
Obviously a pointer of a pointer is handled different, but I'm not exactly sure how it translates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在 [DllImport] 声明中缺少 CallingConvention,它是 Cdecl。
You are missing the CallingConvention in your [DllImport] declaration, it is Cdecl.