NS_InitXPCOM2 编辑

« XPCOM API Reference

Summary

The NS_InitXPCOM2 function initiates use of XPCOM in the calling process.

#include "nsXPCOM.h"

nsresult NS_InitXPCOM2(
  nsIServiceManager** aResult,
  nsIFile* aBinDirectory,
  nsIDirectoryServiceProvider* aAppFileLocationProvider
);

Parameters

aResult
[out] The resulting XPCOM service manager. You may pass null if you are not interested in this return value. The service manager may alternatively be accessed by calling NS_GetServiceManager. The resulting interface pointer is AddRef'd upon return and must either be Release'd explicitly or passed to NS_ShutdownXPCOM when the application is finished with XPCOM.
aBinDirectory
[in] The directory containing the component registry and runtime libraries. Pass null to specify that the current working directory should be used.
aAppFileLocationProvider
[in] The object to be used by XPCOM to locate application specific directories and files (e.g., the user profile, the component registry, etc.). This parameter may be nsnull.

Return Values

The NS_InitXPCOM2 function returns NS_OK if successful. Otherwise, it returns an error code. Some of the possible errors are documented below:

NS_ERROR_NOT_INITIALIZED
Indicates that static globals were not yet initialized, which may happen if this method is called before XPCOM's static initialization code executes. This error may also occur if XPCOM is being initialized after NS_ShutdownXPCOM has been called.

Remarks

You must call NS_InitXPCOM2 (or NS_InitXPCOM3) before proceeding to use XPCOM in a process. The one exception is that you may call NS_NewLocalFile or NS_NewNativeLocalFile to create a nsIFile needed for the aBinDirectory parameter to NS_InitXPCOM2. Many of the XPCOM glue functions and classes are also available prior to XPCOM initialization, including for example nsEmbedCString and nsCOMPtr.

History

This function was finalized for Mozilla 0.9.6. See bug 999147 for details.

See Also

NS_InitXPCOM3, NS_ShutdownXPCOM

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:106 次

字数:4210

最后编辑:7 年前

编辑次数:0 次

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文