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;
上述的回调函数如何转换成C#语言的
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;
上述的回调函数如何转换成C#语言的
http://wenku.baidu.com/view/9f2ef117a216147917112813.html?st=1
//类型定义
[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);试试