我想将c ++代码转换为Delphi。 c ++代码从相机(Hikvision)获取流。我在我的程序中使用了一个dll,我在dll中使用了这个函数:
c ++代码:
NET_DVR_API LONG __stdcall NET_DVR_RealPlay_V30(LONG lUserID, LPNET_DVR_CLIENTINFO lpClientInfo, void(CALLBACK *fRealDataCallBack_V30) (LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* pUser) = NULL, void* pUser = NULL, BOOL bBlocked = FALSE);
delphi代码(我转换):
type
fRealDataCallBack_V30 =procedure(lRealHandle : LongInt; dwDataType: DWORD;pBuffer: PByte; dwBufSize: DWORD; dwUser: DWORD);stdcall;
function NET_DVR_RealPlay_V30 ( lUserID: Longint; lpClientInfo: LPNET_DVR_CLIENTINFO; fRealDataCallBack_V30: fRealDataCallBack_V30; pUser: Pointer; bBlocked: Boolean): Longint;stdcall; external 'HCNetSDK.dll'name 'NET_DVR_RealPlay_V30';
该功能需要回调功能:
c ++代码:
void CALLBACK fRealDataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* dwUser)
{
printf("\nhello");
}
Delphi代码(我转换):
procedure RealDataCallBack(lRealHandle: Longint; dwDataType: Longword; pBuffer: LPByte; dwBufSize: Longword; pUser:Pointer);stdcall;
begin
ShowMessage('hello');
end;
并将该回调函数用作dll函数中的参数:
c ++代码:
NET_DVR_RealPlay_V30(lUserID,&client, fRealDataCallBack,NULL,false);
delphi代码(我转换):
NET_DVR_RealPlay_V30(iLoginID,@lpClientInfo,RealDataCallBack,nil,false);
我的c ++代码完全正常工作,但我的delphi代码无法调用回调函数。