How should I implement IDownloadProgressChangedCallback using WIN32OLE?

237 Views Asked by At

I'd like to download Windows updates by use of WIN32OLE in Ruby. I'm running into issues knowing which COM object to use in order to get the arguments needed by IUpdateDownloader::BeginDownload . For the time being, I can execute the synchronous version of downloading updates, but I would really like to know how I can go about using the asynchronous method.

Something such as the following works now:

require 'win32ole'

muSession = WIN32OLE.new('Microsoft.Update.Session')
availableUpdates = muSession.CreateUpdateSearcher().Search("IsInstalled=0 and Type='Software'").Updates

muUpdateColl = WIN32OLE.new('Microsoft.Update.UpdateColl')
availableUpdates.each do |update|
    update.AcceptEula()
    muUpdateColl.Add(update)
end

updateDownloader = WIN32OLE.new('Microsoft.Update.Session').CreateUpdateDownloader()
updateDownloader.Updates = muUpdateColl

downloadResult = updateDownloader.Download()

However, instead of invoking "Download()", I would like to use "BeginDownload()". How can I instantiate IDownloadProgressChangedCallback (for example). I think doing so may be obvious in C#, but using WIN32OLE, I am not sure how to create the object.

0

There are 0 best solutions below