Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to convert c++ code to Delphi

Status
Not open for further replies.

Engsahar

Programmer
Jun 16, 2016
1
IR
I want to convert c++ code to Delphi. The c++ code is getting stream from camera(Hikvision).I use a dll in my program, I am using this function in dll:
c++ code:
Code:
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 code (that I convert):
Code:
 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';

That function needs callback function:
c++ code :
Code:
  void CALLBACK fRealDataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* dwUser)
        {
        	printf("\nhello");
        }
Delphi code(that I convert):
Code:
  procedure RealDataCallBack(lRealHandle: Longint; dwDataType: Longword; pBuffer: LPByte; dwBufSize: Longword; pUser:Pointer);stdcall;
    begin
     ShowMessage('hello');
    end;

and use that callback function as a parameter in dll function:
c++ code:
Code:
NET_DVR_RealPlay_V30(lUserID,&client, fRealDataCallBack,NULL,false);
delphi code (that I convert):
Code:
 NET_DVR_RealPlay_V30(iLoginID,@lpClientInfo,RealDataCallBack,nil,false);

my c++ code is work completely correctly,but my delphi code can't call callback function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top