[Ruby] InternetExplorer.Application から DWebBrowserEvents2 を導く方法
以下のスクリプトをruby 1.9.0(trunk revision 17942)で実行する。
equire 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
begin
tname = ie.ole_type.name
coclass = ie.ole_typelib.ole_classes.select {|k|
k.ole_type == "Class"
}.select {|k|
k.default_ole_types.select{|dt|
dt.name == tname
}.size > 0
}
coclass.each do |c|
puts "#{c.name}(#{c.progid}) => #{c.default_event_sources.inspect}"
end
ensure
ie.quit
end
実行結果は、
WebBrowser(Shell.Explorer.2) => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
InternetExplorer(InternetExplorer.Application.1) => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
ShellBrowserWindow() => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
となるので、なんとなく2行目から、DWebBrowserEvents2 が使えるんじゃないかと思うことができる。
もう一度、Pythonのソースを調べてみれば、DWebBrowserEvents2を省略できるようになるかも知れない。
| 固定リンク
この記事へのコメントは終了しました。
コメント