码迷,mamicode.com
首页 > 其他好文 > 详细

com接口

时间:2014-05-26 23:24:43      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:style   c   class   blog   code   java   

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接口

标签:style   c   class   blog   code   java   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!