You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.
Embedding Initialization
C++ functions used to initialize and terminate the Gecko embedding layer. The initialization function must be called before attempting to use Gecko.
Note: These are C++ functions, not IDL interfaces.
This function ensures XPCOM is started, creates the component registry if necessary, and starts global services. Notice the "if necessary". As of Mozilla 1.0,
NS_InitEmbedding
no longer causes XPCOM component discovery and registration (autoreg) in optimized builds. If your application requires automatic component discovery and registration to be run in an optimized build, you can add this code:#include "nsXPCOM.h" ... nsCOMPtr<nsIComponentRegistrar> registrar; nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); if (NS_FAILURE(rv)) return rv; rv = registrar->AutoRegister(nsnull); ...Note:
NS_NewLocalFile
should be used to create the file object for the bin directory path in this call. The function may be safely called before the rest of XPCOM or embedding has been initialized.Syntax:
nsresult NS_InitEmbedding(nsILocalFile *aMozBinDirectory, nsIDirectoryServiceProvider *aAppFileLocProvider)Parameters:
aMozBinDirectory:
The Gecko directory containing the component registry and runtime libraries; or usensnull
to indicate the working directory.
aAppFileLocProvider:
The object that specifies to Gecko where to find profiles, component registry preferences and so on; or usensnull
for the default behaviour.
nsresult:
Terminates the Gecko embedding layer. Call this function during shutdown to ensure that global services are unloaded, files are closed and XPCOM is shutdown.
Syntax:
nsresult NS_TermEmbedding()Parameters:
nsresult:
Written by:Ellen Evans | Comments, questions, complaints?
Bug 143387 |