解释下面3句C++代码,在线等

简单才是美 2009-12-07 09:13:37
HINSTANCE hDll;
hDll = LoadLibrary(_T("..\\AliveECGPlugin.dll"));
if( !hDll )
{
hDll = LoadLibrary(_T("AliveECGPlugin.dll"));
}

//DLL
typedef void (*fnBeatDetectorInit)(int nADCUnit, int nADCZero, int nSampleRate);//请解释一下
typedef int (*fnBeatDetectorProcessSample) (int nDatum, double *dHR, char *sAnnotation);
typedef void (*fnFilterInit) (int nSampleRate);
typedef int (*fnFilterProcessSample) (int nDatum);

fnBeatDetectorInit pfnBeatDetectorInit;//请解释一下
fnBeatDetectorProcessSample pfnBeatDetectorProcessSample;
fnFilterInit pfnFilterInit;
fnFilterProcessSample pfnFilterProcessSample;

pfnBeatDetectorInit = (fnBeatDetectorInit) GetProcAddress( hDll,"fnBeatDetectorInit" ); //请解释一下
pfnBeatDetectorProcessSample = (fnBeatDetectorProcessSample) GetProcAddress( hDll,"fnBeatDetectorProcessSample" );
pfnFilterInit = (fnFilterInit) GetProcAddress( hDll,"pfnFilterInit" );
pfnFilterProcessSample = (fnFilterProcessSample) GetProcAddress( hDll,"fnFilterProcessSample" );

...全文
60 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
简单才是美 2009-12-07
  • 打赏
  • 举报
回复
大家都对了,我只是不太确定,尤其是第一个,见过类似于typedef int INT,没见过那种把函数也搞进去,谢谢各位了
DaiDaoDeRen 2009-12-07
  • 打赏
  • 举报
回复
1. typedef void (*fnBeatDetectorInit)(int nADCUnit, int nADCZero, int nSampleRate);
定义了一种类型:fnBeatDetectorInit,这种类型是函数指针,该指针指向一个这样的函数:参数是int nADCUnit, int nADCZero, int nSampleRate,返回类型为void
2. fnBeatDetectorInit pfnBeatDetectorInit
声明并定义了一个函数指针
3.pfnBeatDetectorInit = (fnBeatDetectorInit) GetProcAddress( hDll,"fnBeatDetectorInit" );
函数GetProcAddress()从动态链接库中得到一个函数,返回了函数指针,把该函数指针赋予pfnBeatDetectorInit。

建议LZ看看函数指针的相关内容
bobob 2009-12-07
  • 打赏
  • 举报
回复
typedef void (*fnBeatDetectorInit)(int nADCUnit, int nADCZero, int nSampleRate);
定义函数指针类型,指向的函数原型为:
void fnBeatDetectorInit(int nADCUnit, int nADCZero, int nSampleRate);

fnBeatDetectorInit pfnBeatDetectorInit;
定义函数指针

pfnBeatDetectorInit = (fnBeatDetectorInit) GetProcAddress( hDll,"fnBeatDetectorInit" );
获取dll里面函数地址(函数指针)

这三个其实是一个问题,楼主好好看看函数指针方面的知识
a746027209 2009-12-07
  • 打赏
  • 举报
回复
1. typedef void (*fnBeatDetectorInit)(int nADCUnit, int nADCZero, int nSampleRate);
这是定义函数指针类型...可以用它指向函数
2. fnBeatDetectorInit pfnBeatDetectorInit
声明了一个函数指针对象
3.pfnBeatDetectorInit = (fnBeatDetectorInit) GetProcAddress( hDll,"fnBeatDetectorInit" );
从动态链接库中获得函数的地址,把它赋给函数指针 “fnBeatDetectorInit"的对象"fnBeatDetectorInit",以此来引用函数...

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧