Win32 OLE event sink & Quit

Discussion in 'Ruby' started by Philippe Lang, Apr 21, 2008.

  1. 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 =3D WIN32OLE.new('Access.Application')
    @@access.OpenCurrentDatabase(@database)

    begin

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

    WIN32OLE_EVENT.message_loop until stop_listening

    rescue Exception =3D> 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 Lang
    Philippe Lang, Apr 21, 2008
    #1
    1. Advertising

  2. On Mon, Apr 21, 2008 at 12:28 PM, Philippe Lang
    <> wrote:
    > 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 Lang
    >
    >


    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

    On a side note, this is my third WMI related post in two days. I hope
    I'm not annoying anyone ;-)

    hth,

    Gordon
    Gordon Thiesfeld, Apr 21, 2008
    #2
    1. Advertising

  3. Gordon Thiesfeld wrote:
    > On Mon, Apr 21, 2008 at 12:28 PM, Philippe Lang
    > <> wrote:=20
    >> Hi,
    >>=20
    >> 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.=20
    >>=20
    >> The code I'm playing with looks like:
    >>=20
    >> @@access =3D WIN32OLE.new('Access.Application')
    >> @@access.OpenCurrentDatabase(@database)
    >>=20
    >> begin
    >>=20
    >> @@event_sink =3D WIN32OLE_EVENT.new(@@access, <???>)
    >> stop_listening =3D false
    >> @@event_sink.on_event("Quit") do |*args|
    >> puts "Access application has quit!"
    >> stop_listening =3D true
    >> end
    >>=20
    >> WIN32OLE_EVENT.message_loop until stop_listening
    >>=20
    >> rescue Exception =3D> e
    >> puts e.message
    >> end
    >>=20
    >> 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.=20
    >>=20
    >> Does anyone have an idea?
    >>=20
    >> Thanks,
    >>=20
    >> Philippe Lang
    >>=20
    >>=20

    >=20
    > WMI Events? Here's a VBScript example that will notify when a
    > process terminates.=20
    >=20
    >

    http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=3D=
    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
    Philippe Lang, Apr 22, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick.O.Ige

    Ole ole

    Patrick.O.Ige, Jul 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    490
    Patrick.O.Ige
    Jul 16, 2006
  2. prem
    Replies:
    0
    Views:
    412
  3. Eric Kaplan

    c++ event sink

    Eric Kaplan, Apr 12, 2008, in forum: C++
    Replies:
    7
    Views:
    2,791
    Davis King
    Apr 13, 2008
  4. Ace Fekay [MCT]

    Re: SMTP event sink & Outlook Web Access

    Ace Fekay [MCT], Nov 16, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    495
    Ace Fekay [MCT]
    Nov 16, 2009
  5. Lance Hoffmeyer
    Replies:
    0
    Views:
    238
    Lance Hoffmeyer
    Nov 17, 2003
Loading...

Share This Page