delphi11 海康威视 代码
时间: 2023-07-09 16:48:17 浏览: 116
非常抱歉,我的回答中有误,我之前提供的代码是用于Delphi11开发海康威视SDK的。下面是一个简单的示例代码,演示如何使用Delphi11开发海康威视SDK:
```delphi
unit HkSdkDemo;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, HCNetSDK, Vcl.StdCtrls;
type
TForm1 = class(TForm)
btnLogin: TButton;
btnLogout: TButton;
procedure btnLoginClick(Sender: TObject);
procedure btnLogoutClick(Sender: TObject);
private
{ Private declarations }
m_lUserID: LongInt;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure g_ExceptionCallBack_V30(lHandle: LongInt; pAlarmInfo: Pointer; dwBufLen: DWORD; pUser: Pointer); stdcall;
begin
ShowMessage('Error occured!');
end;
procedure TForm1.btnLoginClick(Sender: TObject);
var
strIP: string;
strPort: Integer;
strUser: string;
strPwd: string;
strDevInfo: NET_DVR_DEVICEINFO_V30;
begin
strIP := '192.168.1.64';
strPort := 8000;
strUser := 'admin';
strPwd := 'admin123';
m_lUserID := NET_DVR_Login_V30(PChar(strIP), strPort, PChar(strUser), PChar(strPwd), strDevInfo);
if m_lUserID < 0 then
begin
ShowMessage('Login failed!');
Exit;
end;
if not NET_DVR_SetExceptionCallBack_V30(0, nil, g_ExceptionCallBack_V30, nil) then
begin
ShowMessage('Set exception callback failed!');
Exit;
end;
ShowMessage('Login successfully!');
end;
procedure TForm1.btnLogoutClick(Sender: TObject);
begin
if not NET_DVR_Logout(m_lUserID) then
begin
ShowMessage('Logout failed!');
Exit;
end;
m_lUserID := -1;
ShowMessage('Logout successfully!');
end;
end.
```
请注意,这只是一个演示代码,实际使用时需要根据具体情况进行修改和完善。同时,为了保证代码的正确性和安全性,建议您也参考海康威视公司的开发文档和示例代码。
阅读全文