110,533
社区成员
发帖
与我相关
我的任务
分享
private void btnSearch_Click(object sender, EventArgs e)
{
//listViewFile.Items.Clear();//清空文件列表
CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();
struFileCond_V40.lChannel = iChannelNum[(int)iSelIndex]; //通道号 Channel number
struFileCond_V40.dwFileType = 0xff; //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
struFileCond_V40.dwIsLocked = 0xff; //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)
//设置录像查找的开始时间 Set the starting time to search video files
struFileCond_V40.struStartTime.dwYear = 2014;
struFileCond_V40.struStartTime.dwMonth = 7;
struFileCond_V40.struStartTime.dwDay = 1;
struFileCond_V40.struStartTime.dwHour = 1;
struFileCond_V40.struStartTime.dwMinute = 1;
struFileCond_V40.struStartTime.dwSecond = 1;
//设置录像查找的结束时间 Set the stopping time to search video files
struFileCond_V40.struStopTime.dwYear = 2014;
struFileCond_V40.struStopTime.dwMonth = 7;
struFileCond_V40.struStopTime.dwDay = 31;
struFileCond_V40.struStopTime.dwHour = 1;
struFileCond_V40.struStopTime.dwMinute = 1;
struFileCond_V40.struStopTime.dwSecond = 1;
//开始录像文件查找 Start to search video files
m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(m_lUserID, ref struFileCond_V40);
if (m_lFindHandle < 0)
{
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
str = "NET_DVR_FindFile_V40 failed, error code= " + iLastErr; //预览失败,输出错误号
MessageBox.Show(str);
return;
}
else
{
//CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30(); ;
CHCNetSDK.NET_DVR_FINDDATA_V40 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V40();
//struFileData.sFileName = @"C:\AMI BIZ\安防监控\HIKSimpleDemo\bin\Debug\test.mp4";
while (true)
{
//逐个获取查找到的文件信息 Get file information one by one.
//int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);
int result = CHCNetSDK.NET_DVR_FindNextFile_V40(m_lFindHandle, ref struFileData);
if (result == CHCNetSDK.NET_DVR_ISFINDING) //正在查找请等待 Searching, please wait
{
continue;
}
else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
{
str1 = struFileData.sFileName;
str2 = Convert.ToString(struFileData.struStartTime.dwYear) + "-" +
Convert.ToString(struFileData.struStartTime.dwMonth) + "-" +
Convert.ToString(struFileData.struStartTime.dwDay) + " " +
Convert.ToString(struFileData.struStartTime.dwHour) + ":" +
Convert.ToString(struFileData.struStartTime.dwMinute) + ":" +
Convert.ToString(struFileData.struStartTime.dwSecond);
str3 = Convert.ToString(struFileData.struStopTime.dwYear) + "-" +
Convert.ToString(struFileData.struStopTime.dwMonth) + "-" +
Convert.ToString(struFileData.struStopTime.dwDay) + " " +
Convert.ToString(struFileData.struStopTime.dwHour) + ":" +
Convert.ToString(struFileData.struStopTime.dwMinute) + ":" +
Convert.ToString(struFileData.struStopTime.dwSecond);
//listViewFile.Items.Add(new ListViewItem(new string[] { str1, str2, str3 }));//将查找的录像文件添加到列表中
}
else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
{
str = "找不到视频文件No file found or no more file found, search is finished ! ";
MessageBox.Show(str);
break; //未查找到文件或者查找结束,退出 No file found or no more file found, search is finished
}
else
{
break;
}
}
}
}