首页 > 其他 > 详细

com接口

时间:2014-05-26 23:24:03      阅读:449      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
1 interface IUnknown
2 {
3     virtual HRESULT __stdcall QueryInterface(const IID & iid, void ** ppv) = 0;
4     virtual ULONG _stdcall AddRef() = 0;
5     virtual ULONG _stdcall Release() = 0;
6 };
bubuko.com,布布扣

 

bubuko.com,布布扣
 1 void foo(IUnknown * pI)
 2 {
 3     IX * pIX = NULL;
 4     HRESULT hr = pI->QueryInterface(IID_IX, (void **)&pIX);
 5     if (SUCCEEDED(hr))
 6     {
 7         pIX->Fx();
 8     }
 9     else
10         ...
11 }
bubuko.com,布布扣

 

bubuko.com,布布扣
 1 HRESULT __stdcall CA::QueryInterface(const IID & iid, void ** ppv)
 2 {
 3     if (iid == IID_IUnknown)
 4         *ppv = static_cast<IUnknown *>this;
 5     else if (iid == IID_IX)
 6         *ppv = static_cast<IX *>this;
 7     else if (iid == IID_IY)
 8         *ppv = static_cast<IY *>this;
 9     else
10         *ppv = NULL;
11 
12     static_cast<IUnknown *>(*ppv)->AddRef();
13     return S_OK;
14 }
bubuko.com,布布扣

 

com接口,布布扣,bubuko.com

com接口

原文:http://www.cnblogs.com/aoun/p/3745119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!