日期:2014-05-18 浏览次数:20783 次
typedef bool(__stdcall * TDevicelist_Callback)(Device_set * aset) ; typedef struct tagDevice_set { Int id; Char _name[32]; Char username[32]; Char userpass[16]; Char ip [16]; Uint port; Byte channel_count; Byte start_channel; Byte device_type; }Device_set;
//类型定义 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] internal struct Device_set { public int id; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string _name; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string username; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string userpass; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string ip; public uint port; public byte channel_count; public byte start_channel; public byte device_type; } internal delegate bool TDevicelist_Callback(ref Device_set ds); //DLL导入 [DllImport("DLL名字", CallingConvention = CallingConvention.StdCall)] internal static extern int PQNVR_GetDeviceList(uint userid, TDevicelist_Callback callback);