public override void Dispose() { CHCNetSDK.NET_DVR_Cleanup(); }
/// <summary> /// 卸载 SDK /// </summary> /// <returns></returns> public static bool CleanupSDK() { return(CHCNetSDK.NET_DVR_Cleanup()); }
/// <summary> /// 释放SDK资源,在程序结束之前调用 /// </summary> public static void NetDVRClearup() { CHCNetSDK.NET_DVR_Cleanup(); WriteMsg("当前设备已释放SDK资源,时间" + DateTime.Now.ToString("yyyy年MM月dd HH时mm分ss秒"), "ok"); }
public void quit() { this.logout(); CHCNetSDK.NET_DVR_Cleanup(); }
private void Exit_Click(object sender, EventArgs e) { CHCNetSDK.NET_DVR_Logout(Login.result); CHCNetSDK.NET_DVR_Cleanup(); Application.Exit(); }
protected override void OnFormClosed(FormClosedEventArgs e) { base.OnFormClosed(e); Dispose(); CHCNetSDK.NET_DVR_Cleanup(); }
/// <summary> /// 使用线程登录 /// </summary> public void ThreadLogin() { //string file = "G:\\天津白泽技术有限公司项目\\天津白泽技术项目源文件等\\CentralEcoCity\\bin\\HCNetSDK.dll"; //InitHikVideoSDK(m_iHCNetDllPath); Thread.Sleep(2000); while (true) { lock (m_oSingleLock) { if (m_lstLoginInfo.Count > 0) { for (int i = 0; i < m_lstLoginInfo.Count; i++) { if (m_lstLoginInfo[i].iHandle == -1) { NET_DVR_USER_LOGIN_INFO struLoginInfo = new NET_DVR_USER_LOGIN_INFO(); NET_DVR_DEVICEINFO_V40 devInfor = new NET_DVR_DEVICEINFO_V40(); devInfor.byRes2 = new byte[246]; devInfor.struDeviceV30.sSerialNumber = new byte[48]; devInfor.byRes2 = new byte[246]; devInfor.struDeviceV30.sSerialNumber = new byte[48]; struLoginInfo.sDeviceAddress = m_lstLoginInfo[i].sStreamIp; struLoginInfo.wPort = Convert.ToUInt16(m_lstLoginInfo[i].sPort); //设备服务端口 struLoginInfo.sUserName = m_lstLoginInfo[i].sUser; //设备登录用户名 struLoginInfo.sPassword = m_lstLoginInfo[i].sPass; //设备登录密码 struLoginInfo.bUseAsynLogin = false; //同步登录方式(异步现在设备不在线时会报错,不知道啥原因) struLoginInfo.byLoginMode = 0; struLoginInfo.byHttps = 2; //m_lstLoginInfo[i].iHandle = HikVideoAPI.NET_HIK_Login_V40(ref struLoginInfo, ref devInfor); m_lstLoginInfo[i].iHandle = CHCNetSDK.NET_DVR_Login_V40(ref struLoginInfo, ref devInfor); //失败 if (m_lstLoginInfo[i].iHandle < 0) { CHCNetSDK.NET_DVR_Logout(m_lstLoginInfo[i].iHandle); CHCNetSDK.NET_DVR_Cleanup(); return; } else { //存储数据用来计算通道号 NET_DVR_IPPARACFG_V40 oIpParaCfgV40 = new NET_DVR_IPPARACFG_V40(); uint dwSize = (uint)Marshal.SizeOf(oIpParaCfgV40); IntPtr ptrIpParaCfgV40 = Marshal.AllocHGlobal((Int32)dwSize); Marshal.StructureToPtr(oIpParaCfgV40, ptrIpParaCfgV40, false); uint dwReturn = 0; //int iGroupNo = 0; //该Demo仅获取第一组64个通道,如果设备IP通道大于64路,需要按组号0~i多次调用NET_DVR_GET_IPPARACFG_V40获取 for (int iGroupNo = 0; iGroupNo < 4; iGroupNo++) { if (CHCNetSDK.NET_DVR_GetDVRConfig(m_lstLoginInfo[i].iHandle, CHCNetSDK.NET_DVR_GET_IPPARACFG_V40, iGroupNo, ptrIpParaCfgV40, dwSize, ref dwReturn)) { oIpParaCfgV40 = (CHCNetSDK.NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ptrIpParaCfgV40, typeof(CHCNetSDK.NET_DVR_IPPARACFG_V40)); m_lstStruIpParaCfgV40.Add(oIpParaCfgV40); } } } //第二种登录 //CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30(); //m_lstLoginInfo[i].iHandle = CHCNetSDK.NET_DVR_Login_V30(m_lstLoginInfo[i].sIp, Convert.ToInt32(m_lstLoginInfo[i].sPort), // m_lstLoginInfo[i].sUser, m_lstLoginInfo[i].sPass, ref DeviceInfo); } } } } } }