QueryInterface

QueryInterface

, , QueryInterface A, QueryInterface C , QueryInterface C A . ,

 QI(QI(A)->B)->C  

 QI(A)->C 

. 4.3 , , , :

 void AssertTransitive(ICar *pCar) {     if (pCar) {          IPlane *pPlane = 0;           // request intermediate type of interface            //                  HRESULT hr = pCar->QueryInterface(IID_IPlane, (void**)&pPlane);         if (SUCCEEDED(hr)) {             IBoat *pBoat1 = 0;               // request terminal type of interface                //                      hr = pPlane->QueryInterface(IID_IBoat, (void**)&pBoat1);             if (SUCCEEDED(hr)) {                 IBoat *pBoat2 = 0;                   // request terminal type through the original pointer                    //                            hr = pCar->QueryInterface(IID_IBoat, (void**)&pBoat2);                   // if the following assertion fails, pCar                   // did not point to a valid   object                   //        ,   pCar                   //          -                 assert(SUCCEEDED(hr));                 pBoat2->Release();             }             pBoat1->Release();         }          pPlane->Release();     }  } 

 . 4.3. queryinterface

QueryInterface , , , , - . , , QueryInterface. QueryInterface , " / " QueryInterface. , , . , QueryInterface .



Suschnost' tehnologii SOM
Essential COM
ISBN: 0201634465
EAN: 2147483647
Year: N/A
Pages: 103
Authors: Don Box

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net