这个DLL是用VC实现的,我现在想用DELPHI来调用。
其中DLL中有一个函数的声明是这样的:
DLLEXPORT_API int __stdcall RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback,void *Context);其中STREAM_DIRECT_READ_CALLBACK 是一个回调函数。在用VC写的例子中是这样调用这个函数的://声明函数指针
typedef int (*STREAM_DIRECT_READ_CALLBACK)(ULONG channelNumber,void *DataBuf,DWORD Length,int FrameType,void *context);
//声明一个相对应的函数
int __cdecl StreamDirectReadCallback(ULONG channelNumber,void *DataBuf,DWORD Length,int FrameType,void *context);
...........
//调用
RegisterStreamDirectReadCallback(::StreamDirectReadCallback,this);也就是说DLL中没有定义StreamDirectReadCallback这个函数,而是在这个VC例子中自己定义的一个函数。////////////////////////////////////////////
下面是本人用DELPHI调用这个函数的写法:
//回调函数类型声明
TYPE
STREAM_DIRECT_READ_CALLBACK=Function(channelNumber:longint;DataBuf:pointer;Length:DWORD;FrameType:integer;context:pointer):integer;stdcall;
  
function StreamDirectReadCallBack(channelNumber:longint;DataBuf:pointer;Length:DWORD;FrameType:integer;context:pointer):integer;stdcall;external 'DS40xxSDK.dll';
 
Function RegisterStreamDirectReadCallBack(StreamDirectReadCallBack:STREAM_DIRECT_READ_CALLBACK;context:pointer):integer;stdcall;external 'DS40xxSDK.dll';................
//调用时是这样写的:
v:=RegisterStreamDirectReadCallBack(@StreamDirectReadCallBack,self);
...编译时提示下面的错误:
“无法定位程序输入点RegisterStreamDirectReadCallBack于动态库DS40xxSDK.dll上” ,
首先,动态库是没有问题的,应为该动态库其他的函数我测试过都可以的。请问一下大家有没有遇到过这种情况,请帮帮忙,谢谢了。

解决方案 »

  1.   

    Function RegisterStreamDirectReadCallBack(StreamDirectReadCallBack:STREAM_DIRECT_READ_CALLBACK;context:pointer):integer;stdcall;external 'DS40xxSDK.dll';回调是“你的” 不是 “动态库的”所以申明:
    Function RegisterStreamDirectReadCallBack(StreamDirectReadCallBack:STREAM_DIRECT_READ_CALLBACK;context:pointer):integer;stdcall;就行了
      

  2.   

    这个我知道啊,但是这样写
    Function RegisterStreamDirectReadCallBack(StreamDirectReadCallBack:STREAM_DIRECT_READ_CALLBACK;context:pointer):integer;stdcall;
    我也试过,这样写的话,还必须要自己实现这个函数的定义。但还是执行的结果还是一样的,还是会报那个错误
      

  3.   

    看样子你是在做视频采集。
    ULONG 是无符号整数,
    Longint是有符号整数把ULONG 翻译成Longword或Cardinal比较贴切一些。
      

  4.   

    楼上说得没错,不知道怎么调用这个DLL呢?