Results 1 to 3 of 3

Thread: [RESOLVED] Close application when computer is shutting down...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Resolved [RESOLVED] Close application when computer is shutting down...

    I have written an application that sits in the systray and monitors a database for me. The problem is that this application is stopping some of my clients computers from shutting down, I assume because the app is still running when the computer is trying to shut down.

    What I need to know is if there is a way that my application can tell when the computer is shutting down, so that I can close my application and therefore allow the computer to shut down.

    I am only running my app on Windows O/S e.g. 2000, XP
    The application is written in VS 2005, .NET 2 and VB.Net language

    Anyway help would be really apreshiated

    Thanks in advance

    Simon
    Last edited by Hack; Mar 17th, 2009 at 01:17 PM. Reason: Added RESOLVED to thread title and green resolve checkmark

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Close application when computer is shutting down...

    Of course, in the WindowClosing event.

    Code:
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            Select Case e.CloseReason
                Case CloseReason.UserClosing
                    MinimizeMeToTray()
                Case CloseReason.WindowsShutDown
                    Me.Close()
                Case Else
                    Me.Close()
            End Select
        End Sub
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Close application when computer is shutting down...

    Jenner,

    Thanks, this was exacually what I needed.

    Simon

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