vc的回调函数如何在delphi中应用(50分)

  • 主题发起人 主题发起人 yxg20803
  • 开始时间 开始时间
Y

yxg20803

Unregistered / Unconfirmed
GUEST, unregistred user!
vc中调用函数:
HIK_PLAYM4_API BOOL __stdcall Hik_PlayM4_SetDisplayCallBack(LONG nPort,void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved));
vc中回调函数
void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved)
***********************************************************************
转换成delphi
回调函数参数
DisplayCBFun = procedure(nPort: integer; pBuf: PChar; nSize: integer; nWidth: integer; nHeight: integer; nStamp: integer; nType: integer; nReserved: integer);
调用函数
function Hik_PlayM4_SetDisplayCallBack(nPort: integer; nDisplayCBFun: DisplayCBFun): LongBool; stdcall;
回调函数
procedure DisplayCBFun1(nPort: integer; pBuf: PChar; nSize: integer; nWidth: integer; nHeight: integer; nStamp: integer; nType: integer; nReserved: integer);stdcall;
调用:
Hik_PlayM4_SetDisplayCallBack(0,@DisplayCBFun1)
这样有问题吗,希望高手指正
错误提示:
Variable required(需求变量)
 
关---注!!!
 
var
pf: DisplayCBFun;
begin
pf:= @DisplayCBFun1;
Hik_PlayM4_SetDisplayCallBack(0,pf);

试试,没调试过, 不过方法是这样,应该没错的
 
谢谢关注,我忘记 函数实现部分加“stdcall;”
procedure DisplayCBFun1(nPort: integer; pBuf: PChar; nSize: integer; nWidth: integer; nHeight: integer; nStamp: integer; nType: integer; nReserved: integer); stdcall;
begin
if SavePic=true then
begin
Hik_PLayM4_ConvertToBmpFile(pBuf,nSize,nWidth,nHeight,nType,'D:/1.bmp') ;
SavePic:=false;
end
else
begin
// ShowMessage('222');
end;
end;
所以出现错误
谢谢关注,散分
 
后退
顶部