2017-07-07 79 views
0

我試圖打開一個應用程序:Bluezone大型機模擬器採取一些措施來自動化一些使用Ruby的大型機進程。Ruby Win32ole HRESULT錯誤代碼:0x80040154

我試圖用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)>' 

我目前運行的是Windows 10的64位,紅寶石2.2.4p230(2015-12 -16修訂版53155)[x64-mingw32]。我試圖運行的應用程序位於C:\ Program Files(x86)\ BlueZone \ 7.1中。

對這個錯誤的任何幫助將是偉大的!

回答

0

事實證明,我的例子中的錯誤是由於使用了64位版本的Ruby引起的。

要解決此問題,請使用32位(X86)版本的Ruby來運行此代碼。

相關問題