简体   繁体   中英

What is the difference between Ruby win32api and win32ole?

A piece of ruby code using win32ole

require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

Some code using win32api

require "Win32API"
message = "This is a sample Windows message box generated using Win32API"
title = "Win32API from Ruby"
api = Win32API.new('user32', 'MessageBox',['L', 'P', 'P', 'L'],'I')
api.call(0,message,title,0)

First one opens up internet explorer and the second one displays a message box. Simply saying both seems to be able to access the OS and make it do stuff. Is win32ole a subset of win32api or is it the other way around? What is the difference between the two?

win32ole is for interoperating with libraries & applications that have been written to act as OLE/COM servers, see What is COM? for an explanation of that technology.

win32api interacts with the operating system API (Win32) which is also where OLE/COM are implemented, but win32ole exists to conveniently abstract away much of the complexities involved in making use of COM via its lower level API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM