C与C++之数据类型(一)

阿里P7移动互联网架构师进阶视频(每日更新中)免费学习请点击:https://space.bilibili.com/474380680

C++与C#数据类型总结

19956127-85f31f50356d5085.png

C#调用C++的DLL搜集整理的所有数据类型转换方式,可能会有重复或者多种方案。

19956127-1fd69f5759922266.png

19956127-45506e0dfb7ddfc4.png

19956127-cd3f8e1ce75f9c44.png

19956127-8d5dfe119e0c72fe.png

19956127-25fe834ae5f05250.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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值