我正在尝试打开一个应用程序: Bluezone Mainframe Emulator,尝试使用Ruby自动化一些大型机流程。
我在尝试用Win32ole打开应用程序时遇到了一个问题。到目前为止,我的代码如下:
require 'win32ole'
class BluezoneRunner
attr_reader :app
def initialize
@type = WIN32OLE_TYPE.new('BZWhll 7.1 Type Library', 'WhllObj')
@app = WIN32OLE.new('BZWhll.WhllObj')
end
def visible=(is_visible)
@app.visible = is_visible
end
def close
@app.Quit
end
end该脚本在分配应用程序对象时失败,并出现以下错误:
Uncaught exception: failed to create WIN32OLE object from `BZWhll.WhllObj'
HRESULT error code:0x80040154
Class not registered
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `initialize'
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `new'
C:/RubyProjects/mksta-sandbox/bluezone-automation/run_ole.rb:9:in `initialize'
C:/RubyProjects/mksta-sandbox/bluezone-automation/bluezone_runner.rb:3:in `new'
C:/RubyProjects/mksta-sandbox/bluezone-automation/bluezone_runner.rb:3:in `<top (required)>'我目前运行的是Windows1064位,Ruby2.2.4p230(2015.12-16Revision 53155) x64-mingw32。我尝试运行的应用程序位于C:\Program Files (x86)\BlueZone\7.1中。
任何关于这个错误的帮助都是很棒的!
发布于 2017-07-10 23:58:58
事实证明,我的例子中的错误是由使用64位版本的Ruby引起的。
要解决此问题,请使用32位(X86)版本的Ruby来运行此代码。
https://stackoverflow.com/questions/44976158
复制相似问题