110,538
社区成员
发帖
与我相关
我的任务
分享
#define P_CLIENT_MAX_ID_LEN 40
struct P_Client_TIME
{
DWORD dwYear;
DWORD dwMonth;
DWORD dwDay;
DWORD dwHour;
DWORD dwMinute;
DWORD dwSecond;
};
struct P_Client_QueryRecordInfo
{
char szChannelID[P_CLIENT_MAX_ID_LEN];
int nSource;
int nRecordType;
char szCardInfo[P_CLIENT_MAX_ID_LEN];
P_Client_TIME sStartTime;
P_Client_TIME sEndTime;
};
CCALLEDBYCS_API int __stdcall P_Client_QueryRecord(P_Client_QueryRecordInfo *info);
[StructLayout(LayoutKind.Sequential)]
public struct P_Client_TIME
{
public UInt32 dwYear;
public UInt32 dwMonth;
public UInt32 dwDay;
public UInt32 dwHour;
public UInt32 dwMinute;
public UInt32 dwSecond;
};
const int P_CLIENT_MAX_ID_LEN = 40;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct P_Client_QueryRecordInfo
{
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = P_CLIENT_MAX_ID_LEN)]
public string szChannelID;
[MarshalAs(UnmanagedType.I4)]
public int nSource;
[MarshalAs(UnmanagedType.I4)]
public int nRecordType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = P_CLIENT_MAX_ID_LEN)]
public string szCardInfo;
public P_Client_TIME sStartTime;
public P_Client_TIME sEndTime;
};
[DllImport("CCalledByCS.dll", EntryPoint = "P_Client_QueryRecord", CallingConvention = CallingConvention.StdCall)]
public extern static int P_Client_QueryRecord(ref P_Client_QueryRecordInfo info);
我测试了,没有发现问题哦。
int size = Marshal.SizeOf(typedef(TagAttr)) ;
IntPtr attrInput = Mashal.AllocHGlobal(count*size);
DBPT.GetTagsAttributeWithPtr(nHandle,count,out errors,ids, attrInput);
for(int i = 0;i< count;i++)
{
IntPtr ptr = (IntPtr)((UInt32)attrInput + i* size);
tagsArray[i] = (TagAttr)Mashal.PtrToStructure(ptr,typeof(TagAttr));
}
Marshal.FreeHGlobal(attrInput);