delphixe ivms-4200 api 读取事件
时间: 2024-01-10 16:03:37 浏览: 211
您可以使用以下 Delphi 代码来读取 iVMS-4200 的事件:
```delphi
procedure GetEvent(const deviceIP: string; const user: string; const password: string);
var
lUserID: LongInt;
struEventParam: NET_DVR_SEARCH_EVENT_PARAM_V40;
struSearchCond: NET_DVR_SEARCHCOND_V40;
struEvent: NET_DVR_SEARCH_EVENT_V40;
dwReturned: DWORD;
dwTotal: DWORD;
i: Integer;
begin
// 登录设备
lUserID := NET_DVR_Login_V40(PChar(deviceIP), 0, PChar(user), PChar(password), nil);
if lUserID < 0 then
begin
ShowMessage('登录设备失败');
Exit;
end;
try
// 设置事件查询参数
ZeroMemory(@struEventParam, SizeOf(struEventParam));
struEventParam.dwSize := SizeOf(struEventParam);
struEventParam.struStartTime.dwYear := 2022;
struEventParam.struStartTime.dwMonth := 1;
struEventParam.struStartTime.dwDay := 1;
struEventParam.struStartTime.dwHour := 0;
struEventParam.struStartTime.dwMinute := 0;
struEventParam.struStartTime.dwSecond := 0;
struEventParam.struEndTime.dwYear := 2022;
struEventParam.struEndTime.dwMonth := 1;
struEventParam.struEndTime.dwDay := 31;
struEventParam.struEndTime.dwHour := 23;
struEventParam.struEndTime.dwMinute := 59;
struEventParam.struEndTime.dwSecond := 59;
// 设置事件查询条件
ZeroMemory(@struSearchCond, SizeOf(struSearchCond));
struSearchCond.dwSize := SizeOf(struSearchCond);
struSearchCond.struStartTime := struEventParam.struStartTime;
struSearchCond.struEndTime := struEventParam.struEndTime;
struSearchCond.dwEventTypeBitMask := $1FF;
struSearchCond.bySearchType := 1;
// 查询事件
ZeroMemory(@struEvent, SizeOf(struEvent));
struEvent.dwSearchEventMode := 0;
struEvent.struSearchParam := struSearchCond;
struEvent.dwMaxResults := 100;
dwReturned := 0;
dwTotal := 0;
if NET_DVR_SearchEvents_V40(lUserID, struEventParam, struEvent, SizeOf(struEvent), @dwReturned, @dwTotal) then
begin
for i := 0 to dwReturned - 1 do
begin
// 处理事件
// ...
end;
end;
finally
// 登出设备
NET_DVR_Logout(lUserID);
end;
end;
```
在上面的代码中,`deviceIP` 是设备的IP地址,`user` 和 `password` 是登录设备的用户名和密码。该函数会查询指定时间范围内的所有事件,并逐个处理它们。请注意,您需要使用 iVMS-4200 SDK 来调用 `NET_DVR_Login_V40`、`NET_DVR_SearchEvents_V40` 和 `NET_DVR_Logout` 函数。
阅读全文