如何引用WIN32对象在MS Windows 7 64bit下的VBScript [英] How to reference to WIN32 object under MS Windows 7 64bit in VBScript

查看:547
本文介绍了如何引用WIN32对象在MS Windows 7 64bit下的VBScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个VBScript在MS Windows 7 32位的本地html页面工作正常,因为它引用MS Windows文本到语音包是32位。

I have this VBScript that works just fine in the local html page under MS Windows 7 32bit because it referenced to MS Windows Text-to-Speech package is 32 bits.

Dim sapi
Set sapi=CreateObject("sapi.spvoice")
  For Each Voice In sapi.getvoices
     I = I + 1
     msgbox "" & (I - 1) & " - " & Voice.GetDescription
Next

我面临的问题是, 7 64安装在 C:\Windows \SysWOW64\

The problem I am facing is that the same package under MS Windows 7 64 is installed under C:\Windows\SysWOW64\

此控制台


C:\Windows \SysWOW64\Speech\SpeechUX\sapi.cpl

C:\Windows\SysWOW64\Speech\SpeechUX\sapi.cpl

它对VBScript有影响因为它使用64位SAPI而不是32个SAPI。

And it has impact to the VBScript above because it uses 64bit SAPI and not 32 SAPI.

所以我想找一个正确的方法/代码来使用

So I would like to find a correct way/code to use

Set sapi=CreateObject("sapi.spvoice")

用于WIN32对象。所以它是有点如何创建ActiveX Win32在Windows 64位下的 HTML页面 的VBScript。

for WIN32 objects. So it is kinda how to create ActiveX Win32 under Windows 64 bit in VBScript of the HTML page.

如何它可以做吗?

推荐答案

当你第一次提出问题,VBScript是在互联网浏览器(假设Internet Explorer作为其他浏览器中内置的对VBScript的支持不存在)

It wasn't clear when you first posed the question that the VBScript was being run inside an Internet Browser (assuming Internet Explorer as built-in support for VBScript in other browsers is none existent).

在处理多种架构时使用相同的规则。而不是客户端是脚本主机 cscript wscript

In the scenario where an Internet Browser is being used the same rules when dealing with multiple architectures applies. Instead of the client being the scripting host (cscript or wscript) the Internet Browser takes on this role.

因此,我们必须确保我们使用正确的浏览器架构版本。

We thus have to make sure we are using the correct architecture version of the browser.


%ProgramFiles%\Internet Explorer\iexplore.exe



x86 (32位)



x86 (32 Bit)


%ProgramFiles(x86)%\Internet Explorer\iexplore.exe

如果Internet浏览器的架构版本错误执行 CreateObject()函数将在注册表的错误部分查找相应的 ProgId code> sapi.spvoice ),可能会导致以下错误:

If the wrong architecture version of the Internet Browser is executed the CreateObject() function will look in the wrong part of the registry for the corresponding ProgId (sapi.spvoice), which can lead to errors like this:


错误:ActiveX组件无法创建对象

代码:800A01AD

源:Microsoft VBScript运行时错误

Error: ActiveX component can't create object
Code: 800A01AD
Source: Microsoft VBScript Runtime Error

这是更常见的应用程序只有32位,因为注册表的64位部分永远不会包含相应的注册的COM组件。

This is more common with applications that are solely 32 bit as the 64 bit part of the registry will never contain the corresponding registered COM components.

有时可能会发现,无论什么原因,你必须手动注册COM DLL,这也可能令人困惑的一些。了解差异很重要。

You may sometimes find that for whatever reason you have to register the COM DLL manually which can also be confusing for some. It's important to understand the differences.


%SystemRoot%\System32\regsvr32.exe



注册x86 COM DLL



Register a x86 COM DLL


%SystemRoot%\SysWOW64\regsvr32.exe

还有一点很重要,适用于64位Windows操作系统,因为32位的只包含64位等效位置。 %ProgramFiles(x86) SysWOW64 是仅特定于64位Windows操作系统的位置。

It's also important to note that this only applies to 64 bit Windows Operating Systems as 32 bit ones will just contain the 64 bit equivalent locations. Both %ProgramFiles(x86) and SysWOW64 are locations specific to 64 bit Windows Operating Systems only.

这篇关于如何引用WIN32对象在MS Windows 7 64bit下的VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆