对 PInvoke 函数的调用导致堆栈不对称问题

2026-02-20 01:28:35

1、解决方法很简单,只要添加属性: CallingConvention=CallingConvention.Cdecl即可。

例如:[DllImport("TestApi.dll")]   internal extern static IntPtr TestApi(); 

添加属性CallingConvention=CallingConvention.Cdecl

改成[DllImport("TestApi.dll",CallingConvention=CallingConvention.Cdecl)]   internal extern static IntPtr TestApi(); 即可。

相关推荐
  • 阅读量:188
  • 阅读量:64
  • 阅读量:59
  • 阅读量:156
  • 阅读量:120
  • 猜你喜欢