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

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

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

    shutdown in windows

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

    How to detect windows shutdown

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

    Detect windows shutdown

    Austin, Jun 22, 2005, in forum: Python
    Replies:
    2
    Views:
    692
    Chris Lambacher
    Jun 23, 2005
  4. Stefan Krah
    Replies:
    0
    Views:
    763
    Stefan Krah
    Jan 11, 2006
  5. Replies:
    7
    Views:
    511
Loading...

Share This Page