Dig*_* Da 7 c# dll marshalling void-pointers
我正在编写我的第一个C#应用程序,但幸运的是,我必须使用void指针(使用返回句柄的DLL).根据我的阅读,有几个选择:
在C#程序中写入我的函数declerations IntPtr而不是void*.例如:public static extern char SupportsWhatever(IntPtr h);
使用ref,例如:public static extern char SupportsWhatever(ref h);
还应该注意,我需要在DLL和C#应用程序之间来回传递信息.
不安全的选项是第一个出现在谷歌上的选项,但出于某些原因,在我的所有功能都感觉不对之前编写关键词unsafe.
有什么建议?