zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    springboot对JPA的支持
    springboot整合redis
    spring boot整合mybatis
    mybatis与spring集成
    mybatis动态sql和分页
    mybatis入门
    使用java代码操作redis
    Redis安装和基本操作
    idea安装及使用
    爬虫
  • 原文地址:https://www.cnblogs.com/Android-Alvin/p/12109556.html
Copyright © 2011-2022 走看看