gpt4 book ai didi

windows - CreateObject 和 Wscript.CreateObject 有什么区别?

转载 作者:可可西里 更新时间:2023-11-01 12:24:55 26 4
gpt4 key购买 nike

有谁知道使用以下选项的原因:

Wscript.CreateObject("some.object")

CreateObject("some.object")

在 VBScript 中?当我找到使用 Wscript.CreateObject 的文档或示例时,我通常使用 CreateObject 重写,因为它似乎总是有效,然后我可以轻松地在 HTA 中重用代码或ASP。但我一直想知道为什么存在此功能,以及如果您在 VBScript 中使用一种或另一种方式,它会产生什么不同。

最佳答案

当你只用一个参数调用它们时,两者之间没有区别。做完全相同的事情。

两者之间的区别只有在调用时使用两个参数时才会明显。声明

Wscript.CreateObject("some.object", "AnotherParam")

CreateObject("some.object", "AnotherParam")

做完全不同的事情:

The VBScript CreateObject function interprets the second parameter as a remote computer name and tries to create the named COM object on that remote computer; in this example, it tries to instantiate an instance of an object with ProgId of "some.object" on a remote computer named "AnotherParam". The WScript CreateObject method interprets the second parameter as a subroutine prefix to be used in handling events from the object. The two GetObject functions are similarly related.

(改编自 TechNet ,“比较 VBScript CreateObject 和 GetObject 函数与 WSH”部分。)

关于windows - CreateObject 和 Wscript.CreateObject 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/787369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com