wuke_615 2023-04-23 11:13 采纳率: 50%
浏览 38
已结题

VB6怎么调用大华网络SDK的DLL声明使用

大家好,最近有个工作是集成大华的摄像头在应用程序中
根据大华网络SDK的开发手册,很多声明VB是困难重重,希望大家有开发过的能否提供一下参考资料。谢谢
例如:

struct NET_DEVICEINFO_Ex{
 BYTE  sSerialNumber[DH_SERIALNO_LEN];
 int   nAlarmInPortNum;
 int   nAlarmOutPortNum;
 int   nDiskNum;
 int   nDVRType;
 int   nChanNum;
 char  Reserved[32];
};

CLIENT_LoginEx2
注册用户到设备的扩展接口,支持一个用户指定设备支持的能力

LLONG CLIENT_LoginEx2(
  char             *pchDVRIP,
  WORD             wDVRPort,
  char             *pchUserName,
  char             *pchPassword,
  EM_LOGIN_SPAC_CAP_TYPE   emSpecCap,
  void             *pCapParam,
  NET_DEVICEINFO_Ex lpDeviceInfo,
  int              *error=0
);

在VB中声明使用我是这么写的,但是毫无反应

Public Type NetDeviceInfoEx
   sSerialNumber(64) As Byte
   nAlarmInPortNum As Integer
   nAlarmOutPortNum As Integer
   nDiskNum As Integer
   nDVRType As Integer
   nChanNum As Integer
   Reserved(32) As Byte
End Type

Public Declare Function CLIENT_Init Lib "dhnetsdk.dll" (ByVal fDisConnect As Long, ByVal dwUser As Long) As Boolean

Public Declare Function CLIENT_Cleanup Lib "dhnetsdk.dll" () As Long

Public Declare Function CLIENT_GetSDKVersion Lib "dhnetsdk.dll" () As Long

Public Declare Function CLIENT_SetConnectTime Lib "dhnetsdk.dll" (ByVal nWaitTime As Long, ByVal nTryTimes As Long) As Long

Public Declare Function CLIENT_LoginEx2 Lib "dhnetsdk.dll" ( _
                                            ByRef DVRIP As String, _
                                            ByVal DVRPort As Long, _
                                            ByRef UserName As String, _
                                            ByRef Password As String, _
                                            EM_LOGIN_SPAC_CAP_TYPE As tagEM_LOGIN_SPAC_CAP_TYPE, _
                                            CapParam As Any, _
                                            Dh_NetDeviceInfoEx As NetDeviceInfoEx, _
                                            ByRef error As Integer _
                                            ) As Long

Dim Info_Ex As NetDeviceInfoEx
Dim DH_Err As Integer

Dim Login_IP As String * 128, Login_User As String * 64, Login_PWD As String * 64
Dim Login_Port As Long

Login_IP = "192.168.1.108"
Login_User = "admin"
Login_PWD = "Test6226335"
Login_Port = 37777

DH_Err = 0

Temp_DH_L = CLIENT_LoginEx2(ByVal Login_IP, Login_Port, ByVal Login_User, ByVal Login_PWD, EM_LOGIN_SPEC_CAP_TCP, vbNull, Info_Ex, DH_Err)
  • 写回答

3条回答 默认 最新

  • AllenGd 大数据领域优质创作者 2023-04-23 11:26
    关注

    基于ChatGPT回答:
    下面是一份基于大华网络SDK的VB6调用示例代码,供参考:

    Public Type NetDeviceInfoEx
       sSerialNumber(63) As Byte
       nAlarmInPortNum As Integer
       nAlarmOutPortNum As Integer
       nDiskNum As Integer
       nDVRType As Integer
       nChanNum As Integer
       Reserved(31) As Byte
    End Type
    
    Public Enum EM_LOGIN_SPAC_CAP_TYPE
        EM_LOGIN_SPEC_CAP_TCP = 0
        EM_LOGIN_SPEC_CAP_WIRELESS = 1
        EM_LOGIN_SPEC_CAP_SSL = 2
        EM_LOGIN_SPEC_CAP_VOIP = 3
        EM_LOGIN_SPEC_CAP_HTTPS = 4
        EM_LOGIN_SPEC_CAP_SECURE = 5
    End Enum
    
    Public Declare Function CLIENT_Init Lib "dhnetsdk.dll" (ByVal fDisConnect As Long, ByVal dwUser As Long) As Boolean
    Public Declare Function CLIENT_Cleanup Lib "dhnetsdk.dll" () As Long
    Public Declare Function CLIENT_GetSDKVersion Lib "dhnetsdk.dll" () As Long
    Public Declare Function CLIENT_SetConnectTime Lib "dhnetsdk.dll" (ByVal nWaitTime As Long, ByVal nTryTimes As Long) As Long
    Public Declare Function CLIENT_LoginEx2 Lib "dhnetsdk.dll" (ByVal sDVRIP As String, ByVal wDVRPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal emSpecCap As EM_LOGIN_SPAC_CAP_TYPE, ByVal pCapParam As Long, ByRef lpDeviceInfo As NetDeviceInfoEx, ByRef error As Integer) As Long
    Public Declare Function CLIENT_Logout Lib "dhnetsdk.dll" (ByVal lUserID As Long) As Boolean
    
    Private Sub Form_Load()
    
        Dim Login_IP As String, Login_User As String, Login_PWD As String, Login_Port As Integer
        Dim Info_Ex As NetDeviceInfoEx
        Dim DH_Err As Integer
        Dim DH_LID As Long
    
        DH_Err = 0
        Login_IP = "192.168.1.108"
        Login_User = "admin"
        Login_PWD = "Test6226335"
        Login_Port = 37777
    
        If CLIENT_Init(AddressOf DisConnectCallBack, 0) = False Then
            MsgBox "初始化SDK失败!"
        Else
            MsgBox "初始化SDK成功!"
        End If
    
        If CLIENT_SetConnectTime(2000, 3) = False Then
            MsgBox "设置连接超时时间失败!"
        Else
            MsgBox "设置连接超时时间成功!"
        End If
    
        DH_LID = CLIENT_LoginEx2(Login_IP, Login_Port, Login_User, Login_PWD, EM_LOGIN_SPEC_CAP_TCP, ByVal 0&, Info_Ex, DH_Err)
        If DH_LID <= 0 Then
            MsgBox "登录设备失败!错误码:" & DH_Err
        Else
            MsgBox "登录设备成功!登录ID:" & DH_LID
        End If
    
    End Sub
    
    Public Sub DisConnectCallBack(ByVal lLoginID As Long, ByVal pchDVRIP As Long, ByVal nDVRPort As Long, ByVal dwUser As Long)
        MsgBox "连接断开!登录ID:" & lLoginID
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        If CLIENT_Logout(DH_LID) = False Then
            MsgBox "注销设备失败!"
        Else
            MsgBox "注销设备成功!"
        End If
        CLIENT_Cleanup
    End Sub
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 5月1日
  • 已采纳回答 4月23日
  • 请详细说明问题背景 4月23日
  • 创建了问题 4月23日

悬赏问题

  • ¥50 matlab,文献复现
  • ¥20 寻找Flink CDC指导,有偿咨询
  • ¥15 cruise如何仿真不同温度下车辆的经济性?
  • ¥20 扑克牌游戏的完整代码
  • ¥88 求帮安装Python架构的vnpy
  • ¥20 逻辑回归法分析品牌知名度和购买意向
  • ¥15 华为云主机-异常连接
  • ¥50 vue 成绩列表 输入成绩,并统计各分数段人数
  • ¥20 请教怎么绕过这个卡密系统 大家交流一下
  • ¥15 设计数字电路得到要求结果