Recognize Windows Shutdown

Discussion in 'Java' started by N. Hamacher, Jun 21, 2004.

  1. N. Hamacher

    N. Hamacher Guest

    Hi,

    how can i catch / recognize a Windows shutdown - means: a shutdown
    signal given by the OS (not by the user)?
    I have to save some data before closing the program.
    Mybe someone could give me a hint?

    greets,

    Nico


    (delete the underscores in the email-address)
     
    N. Hamacher, Jun 21, 2004
    #1
    1. Advertisements

  2. N. Hamacher wrote:

    > Hi,
    >
    > how can i catch / recognize a Windows shutdown - means: a shutdown
    > signal given by the OS (not by the user)?
    > I have to save some data before closing the program.
    > Mybe someone could give me a hint?
    >


    Use a shutdownhook:

    <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)>

    --
    Kind regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Jun 21, 2004
    #2
    1. Advertisements

  3. Christophe Vanfleteren wrote:
    > N. Hamacher wrote:
    >
    >
    >>Hi,
    >>
    >>how can i catch / recognize a Windows shutdown - means: a shutdown
    >>signal given by the OS (not by the user)?
    >>I have to save some data before closing the program.
    >>Mybe someone could give me a hint?
    >>

    >
    >
    > Use a shutdownhook:
    >
    > <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)>
    >


    While that works for command line type applications or demons, it
    usually fails for anything with a gui. (The problem is specific to
    Windows.) I have an application with a shutdown hook installed, however
    if the user logs out the application is terminated before the hook gets
    a chance to run.

    Mark Thornton
     
    Mark Thornton, Jun 21, 2004
    #3
    1. Advertisements

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. hyperbob

    shutdown in windows

    hyperbob, Sep 10, 2004, in forum: Python
    Replies:
    0
    Views:
    373
    hyperbob
    Sep 10, 2004
  2. Austin

    How to detect windows shutdown

    Austin, Apr 6, 2005, in forum: Python
    Replies:
    4
    Views:
    707
    vincent wehren
    Apr 7, 2005
  3. Austin

    Detect windows shutdown

    Austin, Jun 22, 2005, in forum: Python
    Replies:
    2
    Views:
    861
    Chris Lambacher
    Jun 23, 2005
  4. Stefan Krah
    Replies:
    0
    Views:
    949
    Stefan Krah
    Jan 11, 2006
  5. Replies:
    7
    Views:
    612
  6. =?Utf-8?B?UGF1bA==?=

    strart application after shutdown windows xp

    =?Utf-8?B?UGF1bA==?=, Apr 4, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    543
    PlatinumBay
    Jun 4, 2007
  7. rjmccorkle

    windows 7 x64 shutdown

    rjmccorkle, Apr 25, 2011, in forum: Python
    Replies:
    1
    Views:
    494
    Irmen de Jong
    Apr 26, 2011
  8. Dennis Misener

    Detecting Windows Shutdown

    Dennis Misener, Jun 29, 2005, in forum: Ruby
    Replies:
    0
    Views:
    156
    Dennis Misener
    Jun 29, 2005
Loading...