读书人

C# 转 c++ typedef struct解决方法

发布时间: 2013-11-03 15:39:14 作者: rapoo

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];
};

读书人网 >C#

热点推荐