MDN’s new design is in Beta! A sneak peek:

This interface is a class factory that allows for the creation of nsISupports derived classes without specifying a concrete class type.
Inherits from: nsISupports Last changed in Gecko 0.9.5

Method overview

void createInstance(in nsISupports aOuter, in nsIIDRef iid, [retval, iid_is(iid)] out nsQIResult result);
void lockFactory(in PRBool lock);



Creates an instance of the class associated with this factory. Unlike getService, this returns a new instance each time it is called. (See also nsIComponentManager.createInstance.)

void createInstance(
  in nsISupports aOuter,
  in nsIIDRef iid,
  [retval, iid_is(iid)] out nsQIResult result
Pointer to a component that wishes to be aggregated in the resulting instance. This can be nsnull if no aggregation is requested.
The IID of the interface being requested in the component which is being currently created.
Pointer to the newly created instance, if successful.
Exceptions thrown
Indicates that the requested interface is not supported.
Indicates that aggregation is not supported.


This method provides the client a way to keep the component in memory until it is finished with it.

Gecko 1.7 note
As of Gecko 1.7, this method is unused. Most implementations do nothing interesting with this method. It exists primarily for binary compatibility with Microsoft COM's IClassFactory interface.

void lockFactory(
  in PRBool lock
true to lock the factory, and false to unlock the factory.


On WIN32 systems, nsIFactory is ABI-compatible with Microsoft COM's IClassFactory interface.

This interface was frozen for Gecko 0.9.5. See bug 99144 for details. From Gecko 2.0 interfaces are no longer frozen.

See also

Document Tags and Contributors

 Last updated by: Jonathan_Watt,