﻿

{"id":15581,"date":"2023-10-07T11:10:15","date_gmt":"2023-10-07T02:10:15","guid":{"rendered":"https:\/\/www.bitstrong.com\/jp\/?p=15581"},"modified":"2023-12-13T10:43:09","modified_gmt":"2023-12-13T01:43:09","slug":"general-search-for-logs","status":"publish","type":"post","link":"https:\/\/www.bitstrong.com\/jp\/general-search-for-logs\/","title":{"rendered":"\u3010General\u3011Search For Logs"},"content":{"rendered":"<p><strong><span style=\"font-size: 18pt;\">\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0<\/span><\/strong><\/p>\n<div>\/\/<\/div>\n<div>\/\/ Device Network SDK (General)<\/div>\n<div>\/\/ Device Management and Maintenance<\/div>\n<div>\/\/ Search for Logs<\/div>\n<div>\/\/ Sample Code of Searching for Logs<\/div>\n<div>\/\/<\/div>\n<div>#include &lt;stdio.h&gt;<\/div>\n<div>#include &lt;iostream&gt;<\/div>\n<div>#include &#8220;Windows.h&#8221;<\/div>\n<div>#include &#8220;HCNetSDK.h&#8221;<\/div>\n<p>using namespace std;<\/p>\n<div>void main() {<\/div>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Initialize<\/div>\n<div>NET_DVR_Init();<\/div>\n<div>\/\/Set connection time and reconnection time<\/div>\n<div>NET_DVR_SetConnectTime(2000, 1);<\/div>\n<p>NET_DVR_SetReconnect(10000, true);<\/p>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Log in to device<\/div>\n<p>LONG lUserID;<\/p>\n<div>\/\/Login parameters, including device IP address, user name, password, andso on<\/div>\n<div>NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};<\/div>\n<div>struLoginInfo.bUseAsynLogin = 0; \/\/Synchronous login mode<\/div>\n<div>strcpy(struLoginInfo.sDeviceAddress, &#8220;192.0.0.64&#8221;); \/\/IP address<\/div>\n<div>struLoginInfo.wPort = 80; \/\/HTTP port<\/div>\n<div>strcpy(struLoginInfo.sUserName, &#8220;admin&#8221;); \/\/User name<\/div>\n<p>strcpy(struLoginInfo.sPassword, &#8220;abcd1234&#8221;); \/\/Password<\/p>\n<div>\/\/Device information, output parameters<\/div>\n<div>NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};<\/div>\n<div>lUserID = NET_DVR_Login_V40(&amp;struLoginInfo, &amp;struDeviceInfoV40);<\/div>\n<div>if (lUserID &lt; 0)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Login failed, error code: %d\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>NET_DVR_FIND_LOG_COND struFindLogCond = { 0 };<\/div>\n<div>struFindLogCond.dwMainType = 0;<\/div>\n<div>struFindLogCond.dwSubType = 0;<\/div>\n<div>struFindLogCond.dwSelectMode = 0;<\/div>\n<p>struFindLogCond.bOnlySmart = FALSE;<\/p>\n<div>struFindLogCond.struStartTime.wYear = 2019;<\/div>\n<div>struFindLogCond.struStartTime.byMonth = 11;<\/div>\n<div>struFindLogCond.struStartTime.byDay = 2;<\/div>\n<div>struFindLogCond.struStartTime.byHour = 9;<\/div>\n<div>struFindLogCond.struStartTime.byMinute = 0;<\/div>\n<div>struFindLogCond.struStartTime.bySecond = 0;<\/div>\n<div>\/\/struFindLogCond.struStartTime.byISO8601 = 0;<\/div>\n<div>\/\/struFindLogCond.struStartTime.cTimeDifferenceH = 0;<\/div>\n<p>\/\/struFindLogCond.struStartTime.cTimeDifferenceM = 0;<\/p>\n<div>struFindLogCond.struEndTime.wYear = 2019;<\/div>\n<div>struFindLogCond.struEndTime.byMonth = 11;<\/div>\n<div>struFindLogCond.struEndTime.byDay = 3;<\/div>\n<div>struFindLogCond.struEndTime.byHour = 9;<\/div>\n<div>struFindLogCond.struEndTime.byMinute = 0;<\/div>\n<div>struFindLogCond.struEndTime.bySecond = 0;<\/div>\n<div>\/\/struFindLogCond.struEndTime.byISO8601 = 0;<\/div>\n<div>\/\/struFindLogCond.struEndTime.cTimeDifferenceH = 0;<\/div>\n<p>\/\/struFindLogCond.struEndTime.cTimeDifferenceM = 0;<\/p>\n<div>\/\/Search for logs<\/div>\n<div>LONG lLogHandle = NET_DVR_FindDVRLog_V50(lUserID, &amp;struFindLogCond);<\/div>\n<div>if (lLogHandle &lt; 0)<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 printf(&#8220;find log fail, last error %d \\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>NET_DVR_LOG_V50 struLogInfo = {0};<\/div>\n<div>while(true)<\/div>\n<div>{<\/div>\n<div>LONG lRet = NET_DVR_FindNextLog_V50(lLogHandle, &amp;struLogInfo);<\/div>\n<div>if (lRet == NET_DVR_FILE_SUCCESS)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;log:%04d-%02d-%02d %02d:%02d:%02d\\n&#8221;, struLogInfo.struLogTime.wYear, struLogInfo.struLogTime.byMonth, struLogInfo.struLogTime.byDay,\\<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 struLogInfo.struLogTime.byHour, struLogInfo.struLogTime.byMinute, struLogInfo.struLogTime.bySecond,);<\/div>\n<div>}<\/div>\n<div>else if (lRet == NET_DVR_ISFINDING)<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 printf(&#8220;finding \\n&#8221;);<\/div>\n<div>\u00a0 \u00a0 Sleep(5);<\/div>\n<div>continue;<\/div>\n<div>}<\/div>\n<div>else if ((lRet == NET_DVR_NOMOREFILE) || (lRet == NET_DVR_FILE_NOFIND))<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 printf(&#8220;find ending \\n&#8221;);<\/div>\n<div>\u00a0 \u00a0 break;<\/div>\n<div>}<\/div>\n<div>else<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 printf(&#8220;find log fail for illegal get file state \\n&#8221;);<\/div>\n<div>break;<\/div>\n<div>}<\/div>\n<p>}<\/p>\n<div>\/\/Stop searching for logs<\/div>\n<div>if (lLogHandle &gt;= 0)<\/div>\n<div>{<\/div>\n<div>\u00a0 \u00a0 NET_DVR_FindLogClose_V30(lLogHandle);<\/div>\n<p>}<\/p>\n<div>\/\/Log out<\/div>\n<p>NET_DVR_Logout(lUserID);<\/p>\n<div>\/\/Release resources<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<div>}<\/div>\n","protected":false},"excerpt":{"rendered":"\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0 \/\/ \/\/ Device Network SDK (General) \/\/ Device Management and Maintenance \/\/ Search for Logs \/\/ Sample Code of Searching for Logs \/\/ #include &lt;...","protected":false},"author":2,"featured_media":15936,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[107],"tags":[],"class_list":["post-15581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-camera-connection"],"_links":{"self":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/comments?post=15581"}],"version-history":[{"count":8,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15581\/revisions"}],"predecessor-version":[{"id":15705,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15581\/revisions\/15705"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media\/15936"}],"wp:attachment":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media?parent=15581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/categories?post=15581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/tags?post=15581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}