关闭窗户时 [英] While shutting windows down

查看:118
本文介绍了关闭窗户时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我想在关闭窗户的同时编写代码。

我的意思是如果窗口关闭,我的应用程序仍在工作,它确实什么然后关闭应用程序并关闭



谢谢

Hi!
I want to write a code while shutting windows down.
I mean if the windows is going to shut down and my app still working, it does something and then close the app and shut down

thanks

推荐答案

试试这个:



Try this:

Public Sub Handler_SessionEnding(ByVal sender As Object, ByVal e As Microsoft.Win32.SessionEndingEventArgs)
        If e.Reason = Microsoft.Win32.SessionEndReasons.Logoff Then
            MessageBox.Show("User is logging off")
        ElseIf e.Reason = Microsoft.Win32.SessionEndReasons.SystemShutdown Then
            MessageBox.Show("System is shutting down")
        End If
    End Sub

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler Microsoft.Win32.SystemEvents.SessionEnding, AddressOf Handler_SessionEnding
    End Sub 


这篇关于关闭窗户时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆