如何使用 c++来自 javascript xpcom 组件的 xpcom 组件
我用c++开发了一个xpcom组件。我的组件中有 GetHWND() 方法。我还使用 javascript 开发了另一个 xpcom 组件。我想在 javascript xpcom 组件中使用 GetHWND 函数。我正在使用以下代码来执行此操作。
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var myComponent = Components.classes['@dougt/WebLock'].createInstance(Components.interfaces.IWebLock);
myComponent = myComponent.QueryInterface(Components.interfaces.IWebLock);
var res = myComponent.GetHWND(mainWindow.content.document);
但它给出错误“ReferenceError:netscape 未定义”。我进行了谷歌搜索,但没有找到解决方案。
我正在使用 Mozilla Firefox,我希望它也能发挥同样的作用。
请帮助我摆脱这个问题。 提前致谢。
I have developed a xpcom component using c++. I have GetHWND() method in my component. I have also developed another xpcom component using javascript. I want to make use of GetHWND function in javascript xpcom component. I am using following code to do so.
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var myComponent = Components.classes['@dougt/WebLock'].createInstance(Components.interfaces.IWebLock);
myComponent = myComponent.QueryInterface(Components.interfaces.IWebLock);
var res = myComponent.GetHWND(mainWindow.content.document);
But it is giving error as "ReferenceError: netscape is not defined". I did google search but did not find the solution to it.
I am using Mozilla Firefox and I want it to get worked for the same.
Please help me to come out of this problem.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不需要这些:
You don't need these:
我同意 Nickolay 的观点,当你的扩展代码执行时,它具有 chrome 权限,允许你访问 XPCOM 层和组件。
我想看看它是否能与尼古拉提到的台词一起工作。
第二项>> C++ 组件的接口是如何定义的。
XPIDL 不知道 HWND 类型,因此您必须提供一些不同的类型,或者您可以使用本机类型,但 [scriptable] 接口不支持它
I agree with Nickolay, when your extension code is executed it has chrome privileges, which allow you to access XPCOM layer and components.
What I would like to see is if it will work with the lines Nikolay mentioned out.
And second item >> how your interface of C++ component is defined.
XPIDL doesn't aware of HWND type, so you have to provide some different type, or you can use native type but it's not supported by [scriptable] interfaces