阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680
C++与C#数据类型总结
![19956127-85f31f50356d5085.png](https://i-blog.csdnimg.cn/blog_migrate/bbeeaf31a552a55b526cbc098b801591.png)
C#调用C++的DLL搜集整理的所有数据类型转换方式,可能会有重复或者多种方案。
![19956127-1fd69f5759922266.png](https://i-blog.csdnimg.cn/blog_migrate/50513c70b5490cc1469cfbd9c3065ba7.png)
![19956127-45506e0dfb7ddfc4.png](https://i-blog.csdnimg.cn/blog_migrate/76af8a53f566f2e2ca151343bd68ba32.png)
![19956127-cd3f8e1ce75f9c44.png](https://i-blog.csdnimg.cn/blog_migrate/b8bb62e8e17efe409e93872cb7d5ca26.png)
![19956127-8d5dfe119e0c72fe.png](https://i-blog.csdnimg.cn/blog_migrate/c544476bb28fb8e12e75b988d98aac9b.png)
![19956127-25fe834ae5f05250.png](https://i-blog.csdnimg.cn/blog_migrate/77cb6922b9a31fb2aed094ae30904cc8.png)
Win32 Types —- CLR Type
Struct需要在C#里重新定义一个Struct
CallBack回调函数 需要封装在一个委托里,delegate static extern int FunCallBack(string str);
unsigned char ppImage** 替换成 IntPtr ppImage
int& nWidth 替换成 ref int nWidth
int, int&, 则都可用 ref int 对应
双针指类型参数,可以用 ref IntPtr
函数指针使用c++: typedef double (fun_type1)(double); 对应 c#:public delegate double fun_type1(double);
char* 的操作c++: char* 对应 c#: StringBuilder
c#中使用指针:在需要使用指针的地方 加 unsafe
unsigned char对应public byte
typedef void (*CALLBACKFUN1W)(wchar_t*, void* pArg);
typedef void (*CALLBACKFUN1A)(char*, void* pArg);
bool BIOPRINT_SENSOR_API dllFun1(CALLBACKFUN1 pCallbackFun1, void* pArg);
调用方式为
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CallbackFunc1([MarshalAs(UnmanagedType.LPWStr)] StringBuilder strName, IntPtr pArg);
原文链接:https://blog.csdn.net/humanking7/article/details/50981922
阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680