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

2020-12-15  本文已影响0人  XBruce

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;
        };
上一篇下一篇

猜你喜欢

热点阅读