Essential COM

, , . , , , , . , , , . , . (component categories).

- , . . , , . , , .

- , ID , CATID. CATID GUID, . : Implemented Categories Required Categories ( ). , : Simians Mammals ( ). CATID (CATID_Simians CATID_Mammals ). , Chimp , Chimp Implemented Categories GUID :

 [HKCR\CLSID\{CLSID_Chimp}\Implemented Categories\{CATID_Mammals}] [HKCR\CLSID\{CLSID_Chimp}\Implemented Categories\{CATID_Simians}] 

.

 HKEY_CLASSES_ROOT\Component Categories 

, CATID. , . , :

 [HKCR\Component Categories\{CATID_Mammals}]  409="Bears live young" [HKCR\Component Categones\{CATID_Simians}]  409="Eats Bananas" 

, 409, , LCID (locale identifier), U.S.English. .

, . (site interfaces), . , , , ID; , , . , : CATID_HasOxygen CATID_HasWater. , Chimp , , , . Required Categories:

 [HKCR\CLSID\{CLSID_Chimp}\Required Categories\{CATID_HasOxygen}]  [HKCR\CLSID\{CLSID_Chimp}\Required Categories\{CATID_HasWater}] 

, ID

 HKEY_CLASSES_ROOT\Component Categories 

, , . .

, (component category manager). - (CLSID_StdComponentCategoriesMgr), ICatRegister ICatInformation . ICatRegister DLL :

 [object, uuid(0002E012-0000-0000-C000-000000000046)] interface ICatRegister : IUnknown {    // description info for a category    //          typedef struct tagCATEGORYINFO {    CATID catid;   LCID  lcid;   OLECHAR szDescription[128]; } CATEGORYINFO; // register cCts category descriptions  //       cCts  HRESULT RegisterCategories([in] ULONG cCts,                            [in, size_is(cCts)] CATEGORYINFO rgCatInfo[]); // unregister cCategories category descriptions //         cCategories HRESULT UnRegisterCategories([in] ULONG cCategories,                              [in, size_is(cCategories)] CATID rgcatid[]); // indicate a class implements one or more categories //  ,              HRESULT RegisterClassImplCategories([in] REFCLSID rclsid,                                     [in] ULONG cCategories,                                     [in, size_is(cCategories)] CATID rgcatid[]); // deindicate a class implements one or more categories  //    ,            HRESULT UnRegisterClassImplCategories([in] REFCLSID rclsd,                                        [in] ULONG cCategories,                                        [in, size_is(cCategories)] CATID rgcatid[]); // indicate a class requires one or more categories //  ,              HRESULT RegisterClassReqCategories([in] REFCLSID rclsid,                                    [in] ULONG cCategories,                                    [in, size_is(cCategories)] CATID rgcatid[]): // deindicate a class requires one or more categories //    ,              HRESULT UnRegisterClassReqCategones([in] REFCLSID rclsid,                                     [in] ULONG cCategories,                                     [in, size_is(cCategories)] CATID rgcatid[]); } 

- . , .

Chimp :

 // get the standard category manager //        ICatRegister *pcr = 0; HRESULT hr = CoCreateInstance(                CLSID_StdComponentCategoriesMgr, 0,                 CLSCTX_ALL, IID_ICatRegister, (void**)&pcr); if (SUCCEEDED(hr)) {       // build descriptions of each category       //            CATECORYINFO rgcc[4];     rgcc[0].catid = CATID_Simian;     rgcc[1].catid = CATID_Mammal;     rgcc[2].catid = CATID_HasOxygen;     rgcc[3].catid = CATID_HasWater;     rgcc[0].lcid = rgcc[1].lcid = rgcc[2].lcid = rgcc[3].lcid = 0 409;     wcscpy(rgcc[0].szDescription, OLESTR("Eats Bananas"));     wcscpy(rgcc[1].szDescription, OLESTR("Bears live young"));     wcscpy(rgcc[2].szDescription, OLESTR("Provides Oxygen"));     wcscpy(rgcc[3].szDescription, OLESTR("Provides Water"));       // register information regarding categories       //            pcr->RegisterCategories(4, rgcc);       // note that Chimps are Simians and mammals        //  ,   Chimps ( )   Simian        // ( )   Mammal ( )      CATID rgcid[2];     rgcid[0] = CATID_Simian;      rgcid[1] = CATID_Mammal;     pcr->RegisterClassImplCategories(CLSID_Chimp, 2, rgcid);       // note that Chimps require Oxygen and Water       //  ,   Chimps ( )        //     (Oxygen)     (Water)     rgcid[0] = CATID_HasOxygen;      rgcid[1] = CATID_HasWater;     pcr->RegisterClassReqCategories(CLSID_Chimp, 2, rgcid);     pcr->Release(); } 

, API- , .

, . ICatInformation:

 [object, uuid(0002E013-0000-0000-C000-000000000046)] interface ICatInformation : IUnknown {       // get list of known categories        //            HRESULT EnumCategories([in] LCID lcid, [out] IEnumCATEGORYINFO** ppeci);       // get description of a particular category        //            HRESULT GetCategoryDesc([in] REFCATID rcatid,                           [in] LCID lcid, [out] OLECHAR ** ppszDesc);       // get list of classes compatible with specified categories       //      ,          HRESULT EnumClassesOfCategories(                           [in] ULONG cImplemented,        // -1 indicates ignore        // (-1)                              [in,size_is(cImplemented)] CATID rgcatidImpl[],                           [in] ULONG cRequired,        // -1 indicates ignore        // (-1)                              [in,size_is(cRequired)] CATID rgcatidReq[],                           [out] IEnumCLSID** ppenumClsid);       // verify class is compatible with specified categories        //  ,                HRESULT IsClassOfCategories([in] REFCLSID rclsid,                               [in] ULONG cImplemented,                               [in,size_is(cImplemented)] CATID rgcatidImpl[],                               [in] ULONG cRequired,                               [in,size_is(cRequired)] CATID rgcatidReq[]);       // get list of class's implemented categories       //            HRESULT EnumImplCategoriesOfClass([in] REFCLSID rclsid,                                     [out] IEnumCATID** ppenumCatid);       // get list of class's required categories       //      ,      HRESULT EnumReqCategoriesOfClass([in] REFCLSID rclsid,                                    [out] IEnumCATID** ppenumCatid); } 

. (enumerators) 7.

, , Mammal:

 // get the standard category manager  //        ICatInformation *pci = 0; HRESULT hr = CoCreateInstance(                CLSID_StdComponentCategoriesMgr, 0,                 CLSCTX_ALL, IID_ICatInformat1on, (void**)&pci); if (SUCCEEDED(hr)) {       // get the classes that are Simians (ignore required cats)       //    ,   Simian       // (     )     IEnumCLSID *pec = 0;     CATID rgcid[1];     rgcid[0] = CATID_Simian;     hr = pci->EnumClassesOfCategories(1, rgcid, -1, 0, &pec);     if (SUCCEEDED(hr)) {           // walk list of CLSIDs 64 at a time           //     CLSID no 64            enum { MAX = 64 };         CLSID rgclsid[MAX];         do {             ULONG cActual = 0;             hr = pec->Next(MAX, rgclsid, &cActual);             if (SUCCEEDED(hr)) {                  for (ULONG i = 0; i < cActual; i++)                     DisplayClass(rgclsid[i]);             }          }          while (hr == S_OK);         pec->Release();     }     pci->Release(); } 

, . , , .

EnumClassesOfCategories:

 CATID rgimpl[1];  rgimpl[0] = CATID_Simians; CATID rgreq[3];  rgreq[0] = CATID_HasWater; rgreq[1] = CATID_HasOxygen; rgreq[2] = CATID_HasMilk; hr =pci->EnumClassesOfCategories(1, rgimpl, 3, rgreq, &pec); 

(Simians), , (Oxygen), (Water) (Milk). Chimp, , , Simian , .

, , . CATID CLSID

 HKEY_CLASSES_ROOT\CLSID 

CATID CLSID TreatAs, . , Gorilla Simian, :

 [HKCR\CLSID\{CATID_Simian}\TreatAs]  @={CLSID_Gorilla} 

CATID , CLSID:

 // create an instance of the default Simian class  //       Simian,        hr = CoCreateInstance(CATID_Simian, 0, CLSCTX_ALL, IID_IApe, (void**)&pApe); 

, REGDB_E_CLASSNOTREG.



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