CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2001
    Posts
    9

    Windows Shut Down Event

    I want to make an application that would run in the background and trap the Windows Shut Down event to call a function.


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Windows Shut Down Event

    Take a look at the second parameter to the Form QueryUnload event...


  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Windows Shut Down Event

    Dsj means:
    When shutting down, windows gives a quit (=unload all form and close) command to all opened programs. If your program run hidden, it will trig the Query_unload event (with an integer value you have to check as I do not remember right now).
    Matter is: if user terminate your program via Program Manager (on winnt) or hitting ctrl+alt+canc and selecting your program in the list of active task, you may or may not have triggered the query_unload, but Windows may not being shutting down...

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Continue form previous

    Sorry: hitted submit and Ok too fast...
    Now, you may want to call that function on startup of windows, in case you cannot trig the shut down of it: you may do this writing two programs: one should start always at startup (search for run key in registry) and trig on query_unload just to write a new string in RunOnce key of registry. The second should only call the function. The string to write in the RunOnce Key is the path and name + extension of your second exe. This will do the trick: at startup, your second exe will be called, thus activating your function....

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured