How does a Client know if there is a COM server that belongs to it
-
HI I was wondering how a Client can see if a COM server that belongs to him exists in the registry. If an server exists I would like to add an item in the Client's menu. Thank you for your time.
First you need to know either the CLSID or the ProgID of the server. If you know the CLSID then convert the CLSID to a string using StringFromCLSID. Then attempt to open the following registry key: HKEY_CLASSES_ROOT\CLSID\"Your server's CLSID as a string" If the key exists then the server has been installed on this machine. If you have the ProgID, you can use CLSIDFromProgID() to get the CLSID and then proceed as indicated above. The other option, is to use CoCreateInstance() to see if you can actually create the object and then shut it down. However, that might affect performance of your app unacceptably.
-
HI I was wondering how a Client can see if a COM server that belongs to him exists in the registry. If an server exists I would like to add an item in the Client's menu. Thank you for your time.
Call CoGetClassObject() and test to see if it fails with the REGDB_E_CLASSNOTREG error: IClassFactory* pCF = NULL; HRESULT hResult = CoGetClassObject(CLSID_TheObject, NULL, CLSCTX_WHATEVER_YOU_WANT_TO_USE, (void**)&pCF); if (FAILED(hResult)) { if (hResult == REGDB_E_CLASSNOTREG) { // the server's not registered properly... } }