public static configHost getConfigHost() { try { var tmpconfig = new configHost(); tmpconfig.cmsip = System.Configuration.ConfigurationManager.AppSettings["cmsip"].ToString(); tmpconfig.cmsPort = int.Parse(System.Configuration.ConfigurationManager.AppSettings["cmsPort"]); tmpconfig.userName = System.Configuration.ConfigurationManager.AppSettings["userName"].ToString(); tmpconfig.pswd = System.Configuration.ConfigurationManager.AppSettings["pswd"].ToString(); tmpconfig.ValidateType = 0; tmpconfig.UserMacAddr = ""; tmpconfig.UserUsbKey = ""; tmpconfig.Bound = 0; return tmpconfig; } catch (Exception ex) { throw ex; } }
void initDevice(configHost tconfig) { try { var tmpinit = ZxvnmsSDKApi.ZXVNMS_Init(); //var tmpCallback = ZxvnmsSDKApi.ZXVNMS_SetVideoStreamCallback(StreamCallback, _pUser0); var tmpLogin = ZxvnmsSDKApi.ZXVNMS_InitSession(tconfig.cmsip, tconfig.cmsPort, tconfig.userName, tconfig.pswd, tconfig.ValidateType, tconfig.UserMacAddr, tconfig.UserUsbKey, tconfig.Bound); _userid = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetUserID()); _cmsIP = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetCMSIP()); if (ZxvnmsSDKApi.ZXVNMS_QueryDevices(ZXVNMS_DevType.CAMERA) == 0) { while (ZxvnmsSDKApi.ZXVNMS_MoveNext() != -1) { var tmpCamer = new ZXVNMS_Camera2(); tmpCamer.device_id = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetValueStr(ZXVNMS_Camera.device_id)); tmpCamer.device_name = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetValueStr(ZXVNMS_Camera.device_name)); tmpCamer.address = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetValueStr(ZXVNMS_Camera.address)); tmpCamer.control_port = Marshal.PtrToStringAnsi(ZxvnmsSDKApi.ZXVNMS_GetValueStr(ZXVNMS_Camera.control_port)); _list_tcamera.Add(tmpCamer); } } //MessageBox.Show(userid.ToString()); } catch (Exception ex) { ZxvnmsSDKApi.ZXVNMS_Free(); MessageBox.Show(ex.Message); } }