脚本调用ActiveX控件若干问题
来源:互联网 发布:ubuntu 16.04 高分屏 编辑:程序博客网 时间:2024/05/21 00:49
1. 让脚本识别你的com对象的Method和Property。
1.1 有时我们在脚本里(javascript & vbscript)调用com组件的方法或属性时,系统会提示Object doesn't support method or property.我们知道要使com组件和browser client通信,com的接口一定要是继承自IDispatch接口,因为它实现了automation的功能,在idl文件里有一个接口ITest定义为:
[
object,
uuid(ACA3A8D9-7350-45E6-978A-4E44F103C024),
dual,
nonextensible,
helpstring("ITest Interface"),
pointer_default(unique)
]
interface ITest : IDispatch{
[id(1), helpstring("method function1")] HRESULT function1([in] BSTR bstrParam);
};
而且我们要让接口是个dual接口,dual的含义是:that is, the flexibility of both vtable and late binding, thus making the class available to scripting languages as well as C++(MSDN).
1.2 如果你有个custom的接口,叫ITest2,并且你的com对象也继承了它,但是在脚本里却不能访问它的method或property,此时你只要吧ITest2的method或property的声明加到ITes1里就可以,因为ITest1是dual接口且是default,scripting clients are only able to access the [default] IDispatch interface,它的method和property能被brower访问。比如ITest2的定义如下:
[
object,
uuid(8C0D0B02-6C65-44DF-A54A-7D2E29262F93),
helpstring("ITest Interface"),
]
interface ITest2 : IUnkown{
[id(1), helpstring("method function2")] HRESULT function2([in] BSTR bstrParam);
};
然后ITest就是:
interface ITest : IDispatch{
[id(1), helpstring("method function1")] HRESULT function1([in] BSTR bstrParam);
[id(2), helpstring("method function2")] HRESULT function2([in] BSTR bstrParam);
};
coclass MyCOMObject
{
[default] interface ITest;
interface ITest2;
};
这样在脚本里就可以访问接口ITest2的method了。
- 脚本调用ActiveX控件若干问题
- IE10中activex控件调用js脚本
- C#调用ActiveX控件
- 网页调用activex控件
- 网页调用activex控件
- JavaScript调用ActiveX控件
- ActiveX调用 js脚本方法
- activeX控件属性及调用
- WTL8.0 调用 ActiveX 控件
- WIN32 DLL调用ACTIVEX控件
- FTP activeX控件及页面调用
- C#中对ActiveX控件的调用
- 关于网页调用ActiveX控件的补充
- 在html中调用ActiveX控件
- js调用ActiveX(ocx)控件方法
- C#中对ActiveX控件的调用
- 有界面的ActiveX 控件,网页调用
- C# ActiveX控件中调用JavaScript方法
- sql2000备份的数据库还原到sql2005
- SWT(JFace)体验之模拟BorderLayout布局
- 归纳几个扯谈的话题
- 让MDI子窗体默认最大化
- c#读取mac和硬盘号
- 脚本调用ActiveX控件若干问题
- Alter table move 时出现ORA-00600错误
- oracle中文排序
- sscanf用法详解
- 高性能网页开发新20条规则详解
- VS.NET 学习方法论——tuenhai的 VS.NET 学习之旅
- 基于组件的C#农历算法
- 自定义应用程序配置文件(app.config)
- Mastering recursive programming