Christian Biesinger wrote:
Short reply: Very few components support nsIClassInfo, so you can't reliably use it to find the supported interfaces.
Long reply below.


Christopher Lenz wrote:

  cmpmgr->GetClassObjectByContractID(contractID,
      NS_GET_IID(nsISupports), getter_AddRefs(supports));

Hm, GetClassObject? Why are you using this?
Are you aware that this will not give you the component corresponding to this contract id, but just a factory for it?

Well, I'm pretty new to XPCOM. I was under the impression that the class info, if at all implemented, would be provided by the components factory. And your comment below about GenericFactory implementing GetInterfaces() seems to confirm that impression.

Should I be creating an instance of the component and query that for the
nsIClassInfo interface instead? Is it considered okay to create instances of
random components?

For most of the components, I can successfully QueryInterface() to the nsIClassInfo interface, and the GetInterfaces() call succeeds. However, the array returned is always empty (array is NULL, size_is is 0)! Are there any requirements for getting nsIClassInfo to work that I might be missing here?

The GetInterfaces implementation of GenericFactory looks into its moduleinfo structure for a getinterfaces pointer. However, very few components really implement nsIClassInfo, and thus this pointer is null, and hence this function does what it does.

That is too bad :-(


So the alternative to this would be to QueryInterface every component to
every known interface, right? IIUC that is what the XPCOM Component
Viewer[1] does/did. I just hoped there would be a cleaner way to accomplish
this.

Thanks,
Chris

[1] http://www.hacksrus.com/~ginda/cview/
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to