Interacting with the Catalog

Besides understanding the Catalog physical structure, you need to be familiar with how to interact with the three Catalog interfaces and object types (root, collection, and object). This section will walk you through a few programming examples and demonstrate most of what you need to know when programming the Catalog.

The Catalog Root Object

The starting point for everything you do with the Catalog is the root object. You create the root object with the class ID of CLSID_COMAdminCatalog (or the prog-ID of COMAdmin.COMAdminCatalog ) and obtain an interface pointer to the ICOMAdminCatalog interface. You use the ICOMAdminCataloginterface pointer to either invoke root-level methods or access one of the top-level collections by calling the GetCollection( ) method, defined as:

[id(1)] HRESULT GetCollection([in]BSTR bstrCollectionName,
                              [out,retval]IDispatch** ppCatalogCollection);

You can use ICOMAdminCatalog::GetCollection( ) to access only the top-level collections (such as Applications) shown in Figure 6-2. Accessing lower level collections is done differently, and you will see how shortly. GetCollection( ) returns an ICatalogCollection pointer to the specified collection. Once you get the collection you want, you can release the root object. Example 6-1 shows how to access the Applications collection by creating the root object and calling ICOMAdminCatalog::GetCollection( ).

Example 6-1. Accessing a top-level collection such as Applications

HRESULT hres ...

Get COM & .NET Component Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.