美文网首页
C# 调用C++ DLL时,struct参数定义

C# 调用C++ DLL时,struct参数定义

作者: XBruce | 来源:发表于2020-12-15 13:36 被阅读0次

    C++端:

      struct NwkDeviceParam
            {
                char mStrSN[20];
                char mIP[20];
                //Image data buffer.
                char* image;
                int imageSize;
            };
    

    C#端:

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
            public struct NwkDeviceParam
            {
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
                public string mStrSN;
    
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
                public string mIP;
    
                //Image data buffer.
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
                public string image;
                public int imageSize;
            };
    

    相关文章

      网友评论

          本文标题:C# 调用C++ DLL时,struct参数定义

          本文链接:https://www.haomeiwen.com/subject/ticwgktx.html