调用c++接口类
public class CarDeviceDll
{
/*对dll库进行一些初始化*/
[DllImport("IDI.dll")]
public static extern int Init_IDI(string IP, int port); [DllImport("IDI.dll")]
public static extern int Connect_IDI(string IP, int port); /*由客户端定时向服务器发送命令,检测连接状态*/
[DllImport("IDI.dll")]
public static extern void HeartBeat_IDI(); /*从服务端接受数据*/
[DllImport("IDI.dll")]
public static extern int Recv_IDI(ref Client_Data rec); [DllImport("IDI.dll")]
public static extern int QuideInfo_Check(byte DoorNo); [DllImport("IDI.dll")]
public static extern int GetPic_From_Server_IDI(byte[] name, byte[] pic, int len); [DllImport("IDI.dll")]
public static extern int GetPerson_From_Server_IDI(byte[] name, byte[] pic, int len); [DllImport("IDI.dll")]
public static extern int Send_IDI(string sed,int iLen);
[StructLayout(LayoutKind.Sequential, Pack = )]
public struct Client_Data_Head
{
public UInt16 wHeader;
public int iReserved;
public byte byCommand;
public UInt16 wDataLen;
} [StructLayout(LayoutKind.Sequential, Pack = )]
public struct Client_Data
{
public UInt16 wHeader;
public int iReserved;
public byte byCommand;
public UInt16 wDataLen; [MarshalAs(UnmanagedType.ByValTStr,SizeConst=)]
public string szData;
} [StructLayout(LayoutKind.Sequential, Pack = )]
public struct PClientData
{
public UInt16 wHeader;
public int iReserved;
public byte byCommand;
public UInt16 wDataLen; [MarshalAs(UnmanagedType.ByValTStr,SizeConst=)]
public string szData;
} }