Query a specific COM DLL for an interface
-
Hi, Can anybody tell me how to find out if a COM DLL has implemented a specific interface. All I know is the name of the DLL and the CLSID of the interface. I gues Microsfot is doing something similar when they implements add-ins to both Developer Studio and office? Martin Eskildsen
-
Hi, Can anybody tell me how to find out if a COM DLL has implemented a specific interface. All I know is the name of the DLL and the CLSID of the interface. I gues Microsfot is doing something similar when they implements add-ins to both Developer Studio and office? Martin Eskildsen
This is what QueryInterface() does. --Mike-- http://home.inreach.com/mdunn/ The Signature, back by popular demand: Buffy. Pajamas.
-
This is what QueryInterface() does. --Mike-- http://home.inreach.com/mdunn/ The Signature, back by popular demand: Buffy. Pajamas.
Ok - I also thought about QueryInterface in the first place, both I can't figure out how to use it on a spefic DLL (only given the filename of a COM DLL to query the specific DLL wheter it supports the requested interface since). A short example might make my question more clear: I have an executable (MyProg.exe) and two COM DLL's (MyDllA.dll and MyDllB.dll). Both Dll's is allowed to support the requested interface (like add-ins in Developer Studio). In this sample both DLL's supports the interface called IMyInterface, with CLSID CLSID_MyInterface. How can I use QueryInterface in combination with the information above to verify that both DLL's support the interface IMyInterface? Martin Eskildsen
-
Ok - I also thought about QueryInterface in the first place, both I can't figure out how to use it on a spefic DLL (only given the filename of a COM DLL to query the specific DLL wheter it supports the requested interface since). A short example might make my question more clear: I have an executable (MyProg.exe) and two COM DLL's (MyDllA.dll and MyDllB.dll). Both Dll's is allowed to support the requested interface (like add-ins in Developer Studio). In this sample both DLL's supports the interface called IMyInterface, with CLSID CLSID_MyInterface. How can I use QueryInterface in combination with the information above to verify that both DLL's support the interface IMyInterface? Martin Eskildsen
You're confusing DLLs vs. COM servers, and CLSIDs vs. IIDs. First, when creating a COM object, you reference the server by its CLSID, not its filename. CoCreateInstance() takes the CLSID. You also can request an interface in CoCreateInstance(). So if you have the CLSID of one of the servers, and the IID they support (say IID_IMyInterface) you pass both of those to CoCreateInstance() and check the return value to see if it succeeded. --Mike-- http://home.inreach.com/mdunn/ The Signature, back by popular demand: Buffy. Pajamas.
-
You're confusing DLLs vs. COM servers, and CLSIDs vs. IIDs. First, when creating a COM object, you reference the server by its CLSID, not its filename. CoCreateInstance() takes the CLSID. You also can request an interface in CoCreateInstance(). So if you have the CLSID of one of the servers, and the IID they support (say IID_IMyInterface) you pass both of those to CoCreateInstance() and check the return value to see if it succeeded. --Mike-- http://home.inreach.com/mdunn/ The Signature, back by popular demand: Buffy. Pajamas.
In the event that the CLSID of the CoClass object is not known, you can: - use the COM category manager (ICatInformation) and enumerate the objects' CLSIDs at runtime - do category management under your own registry key(s), basically you store the list of COM object CLSIDs and you call CoCreateInstance() on those CLSID and get your interface using QueryInterface() after that