I need to write a function that dynamically extracts the progid from a COM object.
Is this possible?
What’s the best way to do it?
EDIT: All the coclasses I need to process implement IProvideClassInfo
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, there is no guarantee the information is available in first place. Even if you just instantiated an object using ProgID, you might be unale to get it back.
The easiest is to query one of
IPersistand friends (IPersistStreametc.) interfaces, and callIPersist::GetClassIDto obtainCLSID. Then convert to ProgID usingProgIDFromCLSIDor via registry lookup.Another option is to query
IProvideClassInfoandIProvideClassInfo2to access the CLSID of interest in this alternate way.The third option, if none of the two above worked, is to query
IDispatchand attempt to open type library, then iterate through looking up for coclass information.