private void button2_Click(object sender, EventArgs e) { GetDevListResult result = this.tyysocx1.GetCameraList(); if (result.resultCode == 200) { _devices = result.cameraList; foreach (var camera in result.cameraList) { listBox1.Items.Add(camera.cameraName); } } }
//获取设备列表 返回jsonstr public static GetDevListResult GetCameraList() { IntPtr pBuf; int iLength; int ret = HkSDK.OpenSDK_Data_GetDevList(AccessToken, 0, 50, out pBuf, out iLength); string returnJsonStr = Marshal.PtrToStringAnsi(pBuf); GetDevListResult result = null; if (ret == 0) { result = (GetDevListResult)JsonConvert.DeserializeObject(returnJsonStr, typeof(GetDevListResult)); } //Marshal.FreeHGlobal(pBuf); return(result); }