What is the difference between Ruby win32api and win32ole?

438 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.