1,979
社区成员




//这个是调用 ****.dll 为了保密我就用*代替那个dll了,谁要可以传给你
function NET_DVR_Login_V30(sDVRIP: PChar;
wDVRPort: Word;
sUserName: PChar;
sPassword: PChar;
lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): Longint ;stdcall;external '****.dll'
type
NET_DVR_DEVICEINFO_V30 = record
sSerialNumber: Array[0..SERIALNO_LEN-1] of BYTE;
byAlarmInPortNum: BYTE;
byAlarmOutPortNum: BYTE;
byDiskNum: BYTE;
byDVRType: BYTE;
byChanNum: BYTE;
byStartChan: BYTE;
byAudioChanNum: BYTE;
byIPChanNum: BYTE;
byRes1: Array[0..24-1] of BYTE;
end {NET_DVR_DEVICEINFO_V30};
ds: NET_DVR_DEVICEINFO_V30;
var bRet: LongBool;
//这个就是实现的小功能
bRet := NET_DVR_Init();
lUserID := NET_DVR_Login_V30('192.168.1.160', 8000, 'admin', '12345', @ds);
NET_DVR_SetAlarmOut(lUserID,0,1);
//以上代码怎么才能转换成c#的呢?,还有一个Delphi 的dll
public struct NET_DVR_DEVICEINFO_V30
{
byte byAlarmInPortNum;
byte byAlarmOutPortNum;
byte byDiskNum;
byte byDVRType;
byte byChanNum;
byte byStartChan;
byte byAudioChanNum;
byte byIPChanNum;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)]
public byte[] byRes1 ;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = SERIALNO_LEN - 1)]
public byte[] sSerialNumber ;
}
//当我引用******.dll的时候应该得这样写?然后就直接调用 Test.NET_DVR_Login_V30 这个方法?
public class Test
{
[DllImport("******.dll")]
public static extern void NET_DVR_Login_V30(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword, NET_DVR_DEVICEINFO_V30 lpDeviceInfo);
}
public struct NET_DVR_DEVICEINFO_V30
{
byte byAlarmInPortNum;
byte byAlarmOutPortNum;
byte byDiskNum;
byte byDVRType;
byte byChanNum;
byte byStartChan;
byte byAudioChanNum;
byte byIPChanNum;
//结构中不能有实例字段初始值设定项
byte[] byRes1 = new byte[23];
byte[] sSerialNumber = new byte[SERIALNO_LEN - 1];
}
public int NET_DVR_Login_V30(string sDVRIP, ushort wDVRPort, string sUserName, string sPassword, LPNET_DVR_DEVICEINFO_V30 lpDeviceInfo)
{
return 1;
}
public struct NET_DVR_DEVICEINFO_V30
{
byte[] sSerialNumber = new byte[SERIALNO_LEN - 1];
byte byAlarmInPortNum;
byte byAlarmOutPortNum;
byte byDiskNum;
byte byDVRType;
byte byChanNum;
byte byStartChan;
byte byAudioChanNum;
byte byIPChanNum;
byte[] byRes1 = new byte[23];
}