日期:2014-05-18 浏览次数:20799 次
public struct test { public UInt16 wHeader; public UInt32 dwSize; public UInt32 dwID; public Char cCmd; [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 16)] public Char[] sDevID; }
------解决方案--------------------
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 16)]定义长度
------解决方案--------------------
试试这个
/// char[16] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=16)] public string sDevID;
------解决方案--------------------
[StructLayout(LayoutKind.Sequential)] public struct test { public ushort wHeader; public uint dwSize; public uint dwID; public byte cCmd; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] sDevID; }