简体   繁体   中英

how do you compare two arbitrary COM objects (can you get CLSID for arbitrary object?)

I am implementing something in COM where I new up some objects (FilterGraph IFilters in this case) and each time I new up another, I'd like to iterate over the previous list and see if the one I'm about to add is "already on the graph" (already in the list). My first thought was to just use pointer equality (didn't work). Then I thought to compare by CLSID.

Is there a way to get the CLSID from an "arbitrary" COM object?

Closest I could find was: newing up guid's from the display name's substring

Problems accessing the Running Object Table

and what is CLSID of COM object I just ran in Visual Basic (which uses CreateObject however I'm using an EnumMoniker not CreateObject).

(as a note, I've discovered IBaseFilter/IMediaFilter's parent class IPersist has a GetClassID method I can use, but for the sake of curiosity, is there a more generic way...)

CLSID tells object class ("type") of COM object, esp. the identifier you can use with CoCreateInstance to create another instance of an object of the same class.

Comparing non-null CLSIDs you can tell that objects are of the same class, however it does not necessarily mean that the objects are interchangeable. Sometimes you can enumerate public properties and compare them as well, but it is still not reliable approach for arbitrary objects.

Specifically with DirectShow API, registered filters that are instantiated using CoCreateInstance would typically report unique CLSIDs. However those created using monikers (devices, compressors) would rather have shared CLSID and are per-initialized to use specific resource, and filters with the same identifier are not necessarily "equal".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM