从dll创建对象然后调用方法

发布于 2024-11-27 23:16:29 字数 1622 浏览 2 评论 0原文

我正在尝试从 dll 库调用一些方法。我在 JavaScript 和 c++ 中找到了一些示例。我不知道如何使用 C++,所以让我向您展示我为 JavaScript 示例所做的工作:

<html>
<head>
<title>Palm Pad</title>
</HEAD>

<script type="text/javascript" language="JavaScript1.2">

if(window.ActiveXObject) {

    //var ActiveHomeObj = new ActiveXObject("X10.ActiveHome");

} else {

    alert("This script was design to work with Internet Explore 5 and up");

}


function getUSCode(Button1,OnOff)
{
    ActiveHomeObj.SendAction("sendplc","A1 on");
}
</script>

<body>


<a href="javascript:getUSCode(1,'on');">click here to see if method runs</a>

<OBJECT ID="ActiveHomeObj" classid="CLSID:001000AF-2DEF-0208-10B6-DC5BA692C858" codebase="ahscript.dll"  type="application/x-oleobject"></OBJECT>
</body>
</html>

如您所见,这是一个非常简单的 html 页面,只有一个 JavaScript 函数,单击链接时会执行该函数。该脚本的问题是它仅适用于 Internet Explorer,并且在使用它时我收到 在此处输入图像描述 警告。

如果我使用 Internet Explorer 并启用被阻止的内容,我就可以在 ahscript.dll 库上执行 SendAction 方法。

我也想在其他浏览器上运行它,所以如果我可以创建一个 .bat 文件来让我做同样的事情,那就太好了。或者vbs脚本。或任何其他脚本...

如果出于某种原因你知道 AutoIt 这是我尝试过的:

AutoIt

DllCall("ahscript.dll","none","SendAction","str","sendplc","str", "A1 on") 

and

$o = ObjCreate("C:\Users\Virgilio\Desktop\x10\ahscript.dll")
$o.SendAction("sendplc","A1 on")

在vbs中我有类似的东西。

我怎样才能创建一个可执行文件,在执行它时我可以获得与在 Internet Explorer 中打开 html 文件然后启用警告并最后执行 javascrip 函数相同的结果?

I am trying to call some methods from a dll library. I have found some examples in JavaScript and c++ . I don't know how to use c++ so let me show you what I have worked out for the JavaScript example:

<html>
<head>
<title>Palm Pad</title>
</HEAD>

<script type="text/javascript" language="JavaScript1.2">

if(window.ActiveXObject) {

    //var ActiveHomeObj = new ActiveXObject("X10.ActiveHome");

} else {

    alert("This script was design to work with Internet Explore 5 and up");

}


function getUSCode(Button1,OnOff)
{
    ActiveHomeObj.SendAction("sendplc","A1 on");
}
</script>

<body>


<a href="javascript:getUSCode(1,'on');">click here to see if method runs</a>

<OBJECT ID="ActiveHomeObj" classid="CLSID:001000AF-2DEF-0208-10B6-DC5BA692C858" codebase="ahscript.dll"  type="application/x-oleobject"></OBJECT>
</body>
</html>

as you can see this is a very simple html page with just one JavaScript function that gets executed when clicking on the link. The problem with this script is that it only works with internet explorer and when using it I get the enter image description here warning.

If I use internet explorer and I enable the blocked content I am able to execute the SendAction method on the ahscript.dll library.

I will like to run this with other browsers as well so it will be nice if I can create a .bat file that would enable me to do the same thing. Or a vbs script. Or any other script...

if for some reason you know AutoIt here is what I have tried out with it:

AutoIt:

DllCall("ahscript.dll","none","SendAction","str","sendplc","str", "A1 on") 

and

$o = ObjCreate("C:\Users\Virgilio\Desktop\x10\ahscript.dll")
$o.SendAction("sendplc","A1 on")

in vbs I have treid something similar.

How could I create an executable file that when executing it I can get the same result that if I where to open the html file in internet explorer then enable the warning and lastly executing the javascrip function?

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

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

发布评论

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

评论(1

负佳期 2024-12-04 23:16:29

抱歉,你在这里运气不好。

首先,ActiveXObject 特定于 Internet探险家。 FirefoxChrome 不支持。您可以使用 FirefoxChrome 将启用 IE 选项卡,但仍然是 IE。

此外,ActiveX/COM 是 Windows 特有的。您可以使用 Wine 中的 ActiveX/COM,但任何其他操作系统本身都不支持它。

Sorry, you're out of luck here.

First, ActiveXObject is specific to Internet Explorer. Firefox and Chrome do not support it. You can use special plugins for Firefox and Chrome that will enable an IE tab, but that is still IE.

In addition, ActiveX/COM is specific to Windows. You can use ActiveX/COM from Wine, but it is not natively supported by any other OS.

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