当前位置:编程学习 > C#/ASP.NET >>

C#调用非托管dll懂的有木有

struct BATCHADDBCCARD
{
BOOL bAddorDel;
int nCount;
int nCardID[nCount];//nCount和上面的一样
};

说明:
bAddorDel:添加“true”,删除“false”
nCount:取值范围1~1000
nCardID:1~300000
----------------------------------
C#我的写法

[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct BATCHADDBCCARD
{
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public bool bAddorDel;
public const int nCount=1000;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = nCount)]
public int [] nCardID;
}
不知道有没有什么问题
--------------------编程问答-------------------- 每天回帖即可获得10分可用分! --------------------编程问答-------------------- SizeConst 必须是常数.
over.
话说有木有问题自己编译调试一下不就知道了 --------------------编程问答-------------------- 汗...没注意到那个const.
这样二进制序列化后得到的结构体长度不对吧?
lz自己编译运行试试. --------------------编程问答--------------------
补充:.NET技术 ,  非技术区
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,