如何给filter添加接口
2008-12-12 15:47
281 查看
给一个filter添加接口,步骤如下:
1、建立一个声明接口的头文件“Interface.h” ,内容包括指定接口的GUID(使用GuidGen.exe)以及接口函数的声明。
记得加 initguid.h 的include,不然使用时会出现"无法解析的外部符号_IID_"错误
2、在Cfilter类的头文件filter.h开头添加 #include “Interface.h” 。
3、在Cfilter类的声明中继承这个接口 CFilter:public Interface。
4、在Cfilter类的声明中增加Interface接口的函数的声明:
//--------Interface methods----------
STDMETHODIMP SetServerAddr(char* inIP, int inPort);
5、在Cfilter类的定义中实现Interface接口的函数的定义:
//-----------------------Interface methods-----------------------------
STDMETHODIMP CFilter::SetServerAddr(char* inIP, int inPort)
{
……
return S_OK;
}
6、最后别忘了,在CFilter::NonDelegatingQueryInterface函数中添加两行代码,用来向外界暴露该接口:
// Basic COM - used here to reveal our own interfaces
STDMETHODIMP CFilter::NonDelegatingQueryInterface(REFIID riid, void ** ppv)
{
……
if (riid == IID_Interface)
return GetInterface((Interface *) this, ppv);
……
}
至此,filter的接口添加完毕。如果其它应用程序想要用这个接口,那么就像使用其它com组件一样。1、把Interface.h添加到工程里。2、使用前添加 #include “Interface.h”。3、在成功添加filter之后,使用QueryInterface函数获得接口指针即可使用。
1、建立一个声明接口的头文件“Interface.h” ,内容包括指定接口的GUID(使用GuidGen.exe)以及接口函数的声明。
记得加 initguid.h 的include,不然使用时会出现"无法解析的外部符号_IID_"错误
2、在Cfilter类的头文件filter.h开头添加 #include “Interface.h” 。
3、在Cfilter类的声明中继承这个接口 CFilter:public Interface。
4、在Cfilter类的声明中增加Interface接口的函数的声明:
//--------Interface methods----------
STDMETHODIMP SetServerAddr(char* inIP, int inPort);
5、在Cfilter类的定义中实现Interface接口的函数的定义:
//-----------------------Interface methods-----------------------------
STDMETHODIMP CFilter::SetServerAddr(char* inIP, int inPort)
{
……
return S_OK;
}
6、最后别忘了,在CFilter::NonDelegatingQueryInterface函数中添加两行代码,用来向外界暴露该接口:
// Basic COM - used here to reveal our own interfaces
STDMETHODIMP CFilter::NonDelegatingQueryInterface(REFIID riid, void ** ppv)
{
……
if (riid == IID_Interface)
return GetInterface((Interface *) this, ppv);
……
}
至此,filter的接口添加完毕。如果其它应用程序想要用这个接口,那么就像使用其它com组件一样。1、把Interface.h添加到工程里。2、使用前添加 #include “Interface.h”。3、在成功添加filter之后,使用QueryInterface函数获得接口指针即可使用。
相关文章推荐
- 如何给filter添加自定义接口
- 如何给filter添加自定义接口及调用 分类: DirectX 2014-10-24 14:47 455人阅读 评论(0) 收藏
- 如何给filter添加自定义接口及调用
- 如何给filter添加接口
- 如何给filter添加自定义接口 分类: DirectX 2014-10-24 08:59 499人阅读 评论(0) 收藏
- 如何给filter添加自定义接口及调用
- 如何给filter添加自定义接口
- 如何给filter添加自定义接口及调用
- 如何给filter添加自定义接口
- 给dubbo接口添加白名单——dubbo Filter的使用
- source filter 添加 CSourceSeek 接口
- 安装成功的nginx,如何添加未编译安装模块(非覆盖安装http_image_filter_module)
- 如何在Form++开源组态平台添加硬件采集接口
- 如何让Visual Studio 2010添加新类和接口时自动添加public修饰符
- 给dubbo接口添加白名单——dubbo Filter的使用
- java中的FileFilter接口如何使用
- 【百度地图API】如何在地图上添加标注?——另有:坐标拾取工具+打车费用接口介绍
- 给dubbo接口添加白名单——dubbo Filter的使用
- spring boot之如何添加filter
- 如何在Form++开源组态平台添加硬件采集接口