如何创建可在 Javascript 引擎中使用的 ActiveX

发布于 12-25 00:42 字数 325 浏览 4 评论 0原文

您是否知道创建可在 JScript 或 VBScript(基于 Windows 脚本的主机)中使用的 MFC ActiveX 对象的教程?

我的意思是OCX可以用作:

var x= new ActiveXObject("name");

并且这个:

<object id="xxx" classid="CLSID:xxxx">

到目前为止,我发现的所有内容都只允许使用带有html标签的activex,并且它们无法使用脚本引擎进行初始化。

Do you know any tutorial for creating MFC ActiveX objects that can be used in JScript or VBScript (Windows Script Based Host)?

I mean an OCX that can be used as:

var x= new ActiveXObject("name");

and NOT this:

<object id="xxx" classid="CLSID:xxxx">

so far everything that I found just allow using an activex with html tags and they fail to initialize with script engine.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陈独秀2025-01-01 00:42:52

只是添加一些额外的选项:
1. 旧的 vb6 擅长非常简单地创建 ActiveX/COM 组件。
2. 其他语言如Delphi和PowerBasic也可以轻松创建组件。
3. VBScript 可用于创建封装在 com 包装器 WSC(Windows 脚本组件)中的 com 组件。它包含您的类和代码,并且可用作 COM 对象。当通过 COM 调用时,WSC 使用外部脚本组件运​​行时来执行脚本。实际的内部代码可以用其他脚本语言编写,例如 jscript 或 python 或许多其他语言。

Just to add some extra options:
1. Old vb6 was adept at creating ActiveX/COM components quite simply.
2. Other languages like Delphi and PowerBasic can easily create components too.
3. VBScript can be used to create com components which are packaged in a com wrapper WSC (Windows Script Component). This contains your class and code and is usable as a COM object. The WSC uses an external Script Component Runtime to execute your script when called via COM. The actual internal code can be written in other script languages, such as jscript or python or a number of others.

述情2025-01-01 00:42:52

就入门而言,我强烈建议您查看 编写简单 COM/ATL DLL 并将其与 .NET 一起使用的入门教程 作者:就是这样

我尝试了多种不同的技术来创建 ActiveX 对象,并且我发现 ATL C++ 是我最喜欢的技术之一。本教程的关键要点是:

  • 利用 Visual Studio ATL 简单对象向导
  • 用 C++ 命名接口(例如 ISimpleCom
  • 选择 progid(例如 SimpleATLcom.SimpleCom
  • 让 Visual Studio为您生成尽可能多的代码
  • 注册您的 COM DLL

本教程未涵盖的一些内容是:

后者,您已经知道如何执行此操作,但是为了完整起见。在 JScript 中,它是:

var obj = new ActiveXObject("SimpleATLcom.SimpleCom");

在 VBScript 中,它是:

Dim obj
Set obj = CreateObject("SimpleATLcom.SimpleCom")

As far as getting started goes, I highly recommend you check out A Beginner Tutorial for Writing Simple COM/ATL DLL and Using it with .NET by ThatsAlok.

I've tried a number of different techniques in creating ActiveX objects, and, I found the ATL C++ to be one of my favourites. The key essentials of the tutorial are:

  • Utilizing Visual Studio ATL Simple Object wizard
  • Naming the interface in C++ (e.g. ISimpleCom)
  • Choosing a progid (e.g. SimpleATLcom.SimpleCom)
  • Letting Visual Studio generate as much code for you as possible
  • Registering your COM DLL

Some things the tutorial doesn't cover is:

The latter, you already know how to do that, but, for completeness. In JScript, it's:

var obj = new ActiveXObject("SimpleATLcom.SimpleCom");

And, in VBScript, it's:

Dim obj
Set obj = CreateObject("SimpleATLcom.SimpleCom")
只怪假的太真实2025-01-01 00:42:52

FireBreath 插件可以这样使用。它不使用MFC,但是您没有指定为什么需要使用MFC。

FireBreath plugins can be used that way. It doesn't use MFC, but you haven't specified why you need to use MFC.

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