【Card-Based Access Control】Enabling Capture Linkage
サンプルプログラム
//
// Device Network SDK (Card-Based Access Control)
// Alarm and Event Receiving
// Configure Access Control Event
// Sample Code for Enabling Capture Linkage
//
#include <stdio.h>
#include <iostream>
#include “Windows.h”
#include “HCNetSDK.h”
using namespace std;
BOOL CALLBACK MSesGCallback(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)
{
//As the operations with long time comsumption are not allowed in the callback function,
//do not call the API of HCNetSDK.DLL in the callback function.
//The following code is for reference only, actually, processing data in the callback function is not suggested.
//for example, process in the message response function as PostMessage
switch (lCommand)
{
case COMM_ALARM_ACS://Alarm information of access controller
{
NET_DVR_ACS_ALARM_INFO struAcsAlarmInfo = {0};
memcpy(&struAcsAlarmInfo, pAlarmInfo, sizeof(struAcsAlarmInfo));
char szTime[50] = {0};//Alarm time
sprintf(szTime, “%4d-%2d-%2d %2d:%2d:%2d”, struAcsAlarmInfo.struTime.dwYear,
struAcsAlarmInfo.struTime.dwMonth, struAcsAlarmInfo.struTime.dwDay, struAcsAlarmInfo.struTime.dwHour,
struAcsAlarmInfo.struTime.dwMinute, struAcsAlarmInfo.struTime.dwSecond);
char szCardNo[50] = {0};//Card No.
sprintf(szCardNo, “CardNo:%s”, (char *)struAcsAlarmInfo.struAcsEventInfo.byCardNo);
BYTE byCardType = struAcsAlarmInfo.struAcsEventInfo.byCardType;//Card type
DWORD dwCardReaderNo = struAcsAlarmInfo.struAcsEventInfo.dwCardReaderNo;//Card reader No.
DWORD dwDoorNo = struAcsAlarmInfo.struAcsEventInfo.dwDoorNo;//Door No.
if (struAcsAlarmInfo.dwPicDataLen > 0 && struAcsAlarmInfo.pPicData != NULL)
{
char filename[128];
FILE *fSnapPic=NULL;
SYSTEMTIME t;
GetLocalTime(&t);
char chTime[128];
sprintf(filename,”%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d%3.3d”,t.wYear,t.wMonth,t.wDay,
t.wHour,t.wMinute,t.wSecond,t.wMilliseconds);
//Save picture