Vc implementation method is:
Typedef void (CALLBACK * MSGCallBack) (LONG lCommand, NET_DVR_ALARMER * pAlarmer, char * pAlarmInfo, dwords dwBufLen, void * pUser);
NET_DVR_API BOOL __stdcall NET_DVR_SetDVRMessageCallBack_V30 (MSGCallBack fMessageCallBack, void * pUser);
I wrote this in vb: Public Declare Function NET_DVR_SetDVRMessageCallBack_V30 Lib "HCNETSDK. DLL (_
ByVal fMessageCallBack As MSGCallBack, _
ByVal pUser As Long _
) As a Boolean
Public Sub MSGCallBack (_
ByVal lCommand As Long, _
ByVal dwDataType As Long, _
ByVal dwBufSize As Long, _
ByVal pUser As Long)
End Sub
However, ByVal fMessageCallBack As MSGCallBack, _ an error, do excuse me who can teach, thank you.
CodePudding user response:
The building Lord, you don't try to do so:'standard code in the module:
Public Declare Function NET_DVR_SetDVRMessageCallBack_V30 Lib "HCNETSDK. DLL (_
ByVal fMessageCallBack As Long, ByVal pUser) As Long As Boolean
Public Sub MSGCallBack (_
ByVal lCommand As Long, _
ByVal dwDataType As Long, _
ByVal dwBufSize As Long, _
ByVal pUser As Long)
'the function of concrete realization...
'...
'...
'...
'...
End Sub
'example:
Private Sub Command1_Click ()
Dim retVal As Boolean
'NET_DVR_SetDVRMessageCallBack_V30 () call example, XXXXX according to the actual situation of you write
RetVal=NET_DVR_SetDVRMessageCallBack_V30 (AddressOf MSGCallBack, XXXXX)
End Sub
CodePudding user response:
Thank you, I also like this changed tried, but still have error, NET_DVR_SetDVRMessageCallBack_V30 (AddressOf MSGCallBack, XXXXX) to this step will function the illegal jump out, I write so If NET_DVR_SetDVRMessageCallBack_V30 (AddressOf MSGCallBack, IntPtr. Zero) Then'{
The Debug. Print "NET_DVR_SetDVRMessageCallBack_V30 Succ"
'}
C # is an example is that:
M_falarmData=https://bbs.csdn.net/topics/new CHCNetSDK. MSGCallBack (MSGCallBack);
If (CHCNetSDK.NET _DVR_SetDVRMessageCallBack_V30 (m_falarmData, IntPtr. Zero))
{
DebugInfo (" NET_DVR_SetDVRMessageCallBack_V30 Succ ");
}
The else
{
Uint I=CHCNetSDK.NET _DVR_GetLastError ();
NET_DVR_SetDVRMessageCallBack_V30 DebugInfo (" Fail ");
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Function: MSGCallBack
Desc: (callback function)
Input:
Output:
Return:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Public delegate void MSGCallBack (int lCommand, ref NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser);
[DllImport (" HCNetSDK. DLL)]
Public static extern bool NET_DVR_SetDVRMessageCallBack_V30 (MSGCallBack fMessageCallBack, IntPtr pUser);
Public void MsgCallback (int lCommand, ref CHCNetSDK.NET _DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser)
{
MyDebugInfo AlarmInfo=new MyDebugInfo (DebugInfo);
The switch (lCommand)
{
Case CHCNetSDK.COM M_ALARM:
ProcessCommAlarm (ref pAlarmer pAlarmInfo, dwBufLen, pUser);
break;
Case CHCNetSDK.COM M_ALARM_V30:
ProcessCommAlarm_V30 (ref pAlarmer pAlarmInfo, dwBufLen, pUser);
break;
Case CHCNetSDK.COM M_ALARM_RULE:
Enclosing the BeginInvoke (AlarmInfo, "COMM_ALARM_RULE");
break;
Case CHCNetSDK.COM M_TRADEINFO:
Enclosing the BeginInvoke (AlarmInfo, "COMM_TRADEINFO");
break;
Case CHCNetSDK.COM M_IPCCFG:
Enclosing the BeginInvoke (AlarmInfo, "COMM_IPCCFG");
break;
Case CHCNetSDK.COM M_IPCCFG_V31:
Enclosing the BeginInvoke (AlarmInfo, "COMM_IPCCFG_V31");
break;
Default:
break;
}
}
CodePudding user response: