# Win32 OLE event sink & Quit

**URL:** <https://www.ruby-forum.com/t/win32-ole-event-sink-quit/135387>\
**Category:** Ruby\
**Created:** [April 21, 2008, 7:29pm UTC](https://www.ruby-forum.com/t/win32-ole-event-sink-quit/135387 "2008-04-21T19:29:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [April 21, 2008, 7:29pm UTC](https://www.ruby-forum.com/t/win32-ole-event-sink-quit/135387/1 "2008-04-21T19:29:07Z")

</div>

Hi,

I’m trying to setup a win32 ole callback that would notify me that the  
application that was launched has quit, in order to release the process  
from memory.

The code I’m playing with looks like:

```
  @@access = WIN32OLE.new('Access.Application')
  @@access.OpenCurrentDatabase(@database)

  begin

    @@event_sink = WIN32OLE_EVENT.new(@@access, <???>)
    stop_listening = false
    @@event_sink.on_event("Quit") do |*args|
      puts "Access application has quit!"
      stop_listening = true
    end

    WIN32OLE_EVENT.message_loop until stop_listening

  rescue Exception => e
    puts e.message
  end

```

I cannot find any event interface that would notify me that the MS  
Access application has quit. I checked with “Simple OLE Browser”, but no  
luck. And most examples regarding WIN32OLE\_EVENT are done with Internet  
Explorer.

Does anyone have an idea?

Thanks,

Philippe L.

---

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [April 21, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/win32-ole-event-sink-quit/135387/2 "2008-04-21T21:34:20Z")

</div>

On Mon, Apr 21, 2008 at 12:28 PM, Philippe L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,
> 
> Philippe L.

WMI Events? Here’s a VBScript example that will notify when a process  
terminates.

[http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true](http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true)

On a side note, this is my third WMI related post in two days. I hope  
I’m not annoying anyone 😉

hth,

Gordon

---

<div class="post-metadata">

**Author:** ![philpraxis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/77aa72/32.png) [@philpraxis](https://www.ruby-forum.com/u/philpraxis)\
**Post date:** [April 22, 2008, 8:32am UTC](https://www.ruby-forum.com/t/win32-ole-event-sink-quit/135387/3 "2008-04-22T08:32:49Z")

</div>

Gordon T. wrote:

> > ```
> > @@access = WIN32OLE.new('Access.Application')
> > 
> > ```

[http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=t](http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=t)  
rue

Hi,

In fact, I’d like to get notified when the MS Access database quits  
because as long as there is a WIN32OLE object pointing at it, the  
process does not terminate. So I’m afraid this WMI script (the link does  
not work by the way) won’t help here!

Philippe
