Changes

Jump to: navigation, search

Real World Mozilla First XPCOM Component

3 bytes added, 12:05, 19 March 2007
Accessing FirstXpcom from the JavaScript Shell
const cid = "@senecac.on.ca/firstxpcom;1"
print(cid)
* Now create an instance of our component. The value of obj will be nsISupports at this point (i.e., we can't call IFirstXpcom's methods yet).
var obj = Components.classes[cid].createInstance()
* Next, take the the nsISupports object returned above and change it to IFirstXpcom, often referred to as QI (e.g., ''"...you need to QI it to IFirstXpcom..."'').
obj = obj.QueryInterface(Components.interfaces.IFirstXpcom)
* At this point we have the ability to use the IFirstXpcom methods and attributes:
alert(obj.name)
When you run this code, also notice how your C++ '''printf ''' statements are causing messages to stdout in your console window (you may need to scrollback through all the other messages to find them).

Navigation menu