Home > Software engineering >  To replace the callback function that vc realize vb language (hai kang DVR)
To replace the callback function that vc realize vb language (hai kang DVR)

Time:10-19

Recently in vb combined with hai kang DVR video monitoring project, preview, control of the ball mill can be, but want to capture the alarm message when using the callback function of cameras, I don't know how to convert in vb,
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:

refer to the second floor ysfxincsdn 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 )
'{
The Debug. Print "NET_DVR_SetDVRMessageCallBack_V30 Succ"
'}
.
}


You the IntPtr. Zero is what east east???????
According to the function prototype "parameters", should be a "user name" string pointer...

CodePudding user response:

I followed the c # example, IntPtr. Zero is Zero

CodePudding user response:

You also made the kang secondary development of DVR? Can consult your code? (mainly is to get alarm channel number the) first contact, I am familiar with vb is less, but the existing project was developed by vb, so difficult, 475076893 @qq.com

CodePudding user response:

I didn't make these, write code that's just a hobby,

CodePudding user response:

reference 4 floor ysfxincsdn response:
I tracked the c # example, IntPtr. Zero is 0

Then you can also send a 0 to it, try ah,

Also, I doubt it is your MSGCallBack () is not correct errors in the processing,
You can try first and put it inside the code commented out entirely,
Then, write one, two other common code, such as a local Long variables, and then write a randomly assigned a value,
If can run under the IDE, you can write a word: debug. Print lCommand, dwDataType, dwBufSize, pUser
Or write sentences msgbox statement, can be performed to, will not cause errors,

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related