http://expert.csdn.net/Expert/topic/1849/1849551.xml?temp=.0761072
解决方案 »
- C# WINFORM下面需求一个HTML编辑器。。。求类似控件
- 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
- 为什么网页中的标签有时不能绑定
- 同一窗体显示两个样式的问题?
- 气!急!急!为什么每次执行这段代码,页面设置对话框的页边距值都不一样?
- 急聘5年左右经验的.net developer
- DataGrid的问题
- 关于C#操作word的表格,并且以另存为问题~好人一生平安~
- 刚刚学习C#,怎样才能学的更好?
- Visual Studio.Net RC2都出来N段时间了,为什么还不使?!
- 各位达人,怎么做一个windows中类似ip地址输入或时间输入的TextBox啊?
- 大家帮个忙啊,项目经理等等看看这个东西的报价多少比较合适。~~~~~
{
byte RecvType;
[MarshalAs (UnmanagedType.ByValArray,SizeCount=22)]
byte SrcNo[22];
byte TpUid;
byte TpUdhi;
byte Encoded;
int MsgLength;
[MarshalAs (UnmanagedType.ByValArray,SizeCount=3)]
byte[] Msg;
};
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 22)]
public string SrcNo;
public byte TpUid;
public byte TpUdhi;
public byte Encoded;
public byte MsgLength;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 162)]
public string Msg;
------------
还剩一个Msg没取到值,哪位大侠助一力啊!
我看到有这样定义的
[StructLayout(LayoutKind.Explicit]
public struct Rect {
[FieldOffset(0)] public int left;
[FieldOffset(4)] public int top;
[FieldOffset(8)] public int right;
[FieldOffset(12)] public int bottom;
}
不知道换在我这个地方应该怎么用?
[StructLayout(LayoutKind.Sequential)]
struct Deliver
{
byte RecvType;
[MarshalAs(UnmanagedType.LPArray,SizeConst=22)]
byte SrcNo[22];
byte TpUid;
byte TpUdhi;
byte Encoded;
UInt16 MsgLength;
[MarshalAs(UnmanagedType.LPArray,SizeConst=162)]
byte Msg[162];
};
)
你这是C#么?
[StructLayout(LayoutKind.Sequential)]
struct Deliver
{
byte RecvType;
[MarshalAs(UnmanagedType.LPArray,SizeConst=22)]
byte[] SrcNo;
byte TpUid;
byte TpUdhi;
byte Encoded;
UInt16 MsgLength;
[MarshalAs(UnmanagedType.LPArray,SizeConst=162)]
byte[] Msg;
};
[StructLayout(LayoutKind.Sequential)]
struct Deliver
{
public byte RecvType;
[MarshalAs (UnmanagedType.ByValArray,SizeCount=22)]public byte[] SrcNo;
public byte TpUid;
public byte TpUdhi;
public byte Encoded;
public ushort MsgLength;
[MarshalAs (UnmanagedType.ByValArray,SizeCount=162)]public byte[] Msg;
};
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]
struct Deliver
{
public byte RecvType;
[MarshalAs (UnmanagedType.ByValArray,SizeCount=22)]public byte[] SrcNo;
public byte TpUid;
public byte TpUdhi;
public byte Encoded;
public ushort MsgLength;
[MarshalAs (UnmanagedType.ByValTStr,SizeCount=162)]public string Msg;
};