componentscom+

How to Add ICatalogObject to ICatalogCollection?


Trying to add a COM+ application and add COM registered in the 32-bit registry as a component to the added application with C++.

Adding a COM+ application was solved by adding ICatalogObject to ICatalogCollection.

Get_Key was received from the added ICatalogObject and the Components Collection was received to add components as shown below.

ICatalogCollection->GetCollection(L"Components", varAppKey, (IDispatch**)&pCompCollection);

I also found the ICatalogObject (pApp) of COM registered in the 32-bit registry. Finally, the only thing left to do was add an empty ICatalogObject to pCompCollection and enter the information of the found pApp.

The problem is that adding an empty ICatalogObject to pCompCollection always fails (E_NOTIMPL Not implemented).

ICatalogObject* pNewApp = nullptr
hr = pCollection->Add((IDispatch**)&pNewApp);
// hr: E_NOTIMPL Not implemented

text

While trying to find the cause, I found that get_AddEnabled in pCompCollection always returns false.

VARIANT_BOOL var_b;
pCompCollection->get_AddEnabled(&var_b); // var_b: 0

I don't know if this is the cause or if get_AddEnabled becomes false as a result of some other reason, or if it is impossible to add COM as a component with C++ code in the first place.

Always proceeded in administrator mode.

I'm asking for advice.


Solution

  • This was resolved by including comadmin and then importing it.

    // #include <comadmin.h> // #include <comsvcs.h>

    #import "c:\windows\system32\com\Comadmin.dll" no_namespace