日期:2014-05-17  浏览次数:21134 次

C# 转 c++ typedef struct
typedef struct
{
int Count;
struct
{
int Press;
int Code;
}Keys[6];
}VK_SENDKEY,*PVK_SENDKEY;


请问各位大神,这种c++格式转换成c#怎么表达啊,要调用c++编译的dll啊。
typedef?struct

------解决方案--------------------
[StructLayout(LayoutKind.Sequential)]
public struct Key
{
    public int Press;
    public int Code;
}
[StructLayout(LayoutKind.Sequential)]
public struct VK_SENDKEY
{
    public int Count;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
    public Key[] Keys;
}

------解决方案--------------------
KeyData.Keys = new Key[6];
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
------解决方案--------------------
struct _Key_
{
  int Press;
  int Code;
};

struct VK_SENDKEY
{
    int Count;
    _Key_ Keys[]=new _Key_[6];
};