动态库中结构体: struct CICinf { int Data1, Data2, Data3, Data4, Data5, Data6, Data7, Data8, Data9, Data10; int Data11, Data12, Data13, Data14, Data15, Data16, Data17, Data18, Data19, Data20; int Data21, Data22, Data23, Data24, Data25, Data26, Data27, Data28, Data29, Data30; };
dll 动态库提供的函数:int __stdcall ICWriteXiMCard(int& CardType,int& Flag, CICinf* Inf );
c#调用这个函数 参数要怎么传???
我的 c#写法: [StructLayout(LayoutKind.Sequential)] public struct CICinf { public int Data1; public int Data2; public int Data3; public int Data4; public int Data5; public int Data6; public int Data7; public int Data8; public int Data9; public int Data10; public int Data11; public int Data12; public int Data13; public int Data14; public int Data15; public int Data16; public int Data17; public int Data18; public int Data19; public int Data20; public int Data21; public int Data22; public int Data23; public int Data24; public int Data25; public int Data26; public int Data27; public int Data28; public int Data29; public int Data30; }
int cardType = 0;
int flag = 1;
CICinf Inf = new CICinf();
int state = ICReadXiMCard(ref cardType,ref flag,ref Inf);
[DllImport(dllPath, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern int ICReadXiMCard(ref int CardType, ref int Flag, ref CICinf Inf);
这样写 报托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配
求 大佬 指导指导 万分感谢