CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Program to detect windows shut down

    Hi,
    I have an application and this application needs to close when the window shutdown happen. How can i detect that the system is shutting down from a C# program
    If i helped you, Please rate me

    Visit http://www.octopusplus.com

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Program to detect windows shut down

    if it is a windows application, use the FormClosing event

    Code:
    private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
      if (e.CloseReason == CloseReason.WindowsShutDown) {
        //
      }
    }

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Program to detect windows shut down

    Subscribe to the event System.Events.SessionEnded.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

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