Here is my C++ code, I can't login to the HikVision DS-K2600 Device, because I receive back an Login failed with error Code -41 NET_DVR_ALLOCRESOURCE_ERROR.
Thanks in advance
#include <stdio.h>
#include <iostream>
#include <afx.h>
#include "Windows.h"
#include "HCNetSDK.h"
#pragma comment(lib, "HCNetSDK.lib")
#pragma comment(lib, "HCCore.lib")
using namespace std;
void main()
{
/---------------------------------------
/Initialize
NET_DVR_Init();
/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
/---------------------------------------
/Initialize
NET_DVR_Init();
/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
/---------------------------------------
/Log in to device
LONG lUserID;
/Login parameters, including device IP address, user name, password, and so on
NET_DVR_USER_LOGIN_INFO struLoginInfo = { 0 };
struLoginInfo.bUseAsynLogin = 0; /Synchronous login mode
strcpy_s(struLoginInfo.sDeviceAddress, "192.168.0.64"); /Device IP address
struLoginInfo.wPort = 8000; /Device service port number
strcpy_s(struLoginInfo.sUserName, "admin"); /User name
strcpy_s(struLoginInfo.sPassword, "Mobiliere.10"); /Password
/Device information, output parameter
NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = { 0 };
lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
if (lUserID < 0)
{
printf("Login failed, error code: %d\n", NET_DVR_GetLastError());
NET_DVR_Cleanup();
return;
}
/Open door, take door 1 as an example
BOOL bRet;
LONG lGatewayIndex = 1;/Access controller No., starts from 1, -1: control all doors
DWORD dwStaic = 1;/Command No.: 0-Close, 1-Open, 2-Remain Open, 3-Remain Closed
bRet = NET_DVR_ControlGateway(lUserID, lGatewayIndex, dwStaic);
if (!bRet)
{
printf("NET_DVR_ControlGateway failed, error:%d\n", NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;
}
/---------------------------------------
/Exit
Sleep(5000);
/Log out
NET_DVR_Logout(lUserID);
/Release SDK resource
NET_DVR_Cleanup();
return;
}
Thanks in advance
#include <stdio.h>
#include <iostream>
#include <afx.h>
#include "Windows.h"
#include "HCNetSDK.h"
#pragma comment(lib, "HCNetSDK.lib")
#pragma comment(lib, "HCCore.lib")
using namespace std;
void main()
{
/---------------------------------------
/Initialize
NET_DVR_Init();
/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
/---------------------------------------
/Initialize
NET_DVR_Init();
/Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
/---------------------------------------
/Log in to device
LONG lUserID;
/Login parameters, including device IP address, user name, password, and so on
NET_DVR_USER_LOGIN_INFO struLoginInfo = { 0 };
struLoginInfo.bUseAsynLogin = 0; /Synchronous login mode
strcpy_s(struLoginInfo.sDeviceAddress, "192.168.0.64"); /Device IP address
struLoginInfo.wPort = 8000; /Device service port number
strcpy_s(struLoginInfo.sUserName, "admin"); /User name
strcpy_s(struLoginInfo.sPassword, "Mobiliere.10"); /Password
/Device information, output parameter
NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = { 0 };
lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
if (lUserID < 0)
{
printf("Login failed, error code: %d\n", NET_DVR_GetLastError());
NET_DVR_Cleanup();
return;
}
/Open door, take door 1 as an example
BOOL bRet;
LONG lGatewayIndex = 1;/Access controller No., starts from 1, -1: control all doors
DWORD dwStaic = 1;/Command No.: 0-Close, 1-Open, 2-Remain Open, 3-Remain Closed
bRet = NET_DVR_ControlGateway(lUserID, lGatewayIndex, dwStaic);
if (!bRet)
{
printf("NET_DVR_ControlGateway failed, error:%d\n", NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;
}
/---------------------------------------
/Exit
Sleep(5000);
/Log out
NET_DVR_Logout(lUserID);
/Release SDK resource
NET_DVR_Cleanup();
return;
}