添加托盘图标控件,并设置好其Icon属性,然后添加如下代码:
在阿鲁科尔沁等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、网站制作 网站设计制作按需制作,公司网站建设,企业网站建设,成都品牌网站建设,网络营销推广,外贸网站制作,阿鲁科尔沁网站建设费用合理。
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub
在SystemEvents类中 可以 用户试图注销或关闭系统时发生。 (当用户试图注销或关闭系统时发生。当用户试图注销或关闭系统时发生。) 这个 事件处理函数中 可以找到如下方法
Private Shared WM_QUERYENDSESSION As Integer = H11
Private Shared systemShutdown As Boolean = False
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot")
systemShutdown = True
End If
' If this is WM_QUERYENDSESSION, the closing event should be raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc
Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If (systemShutdown) Then
' Reset the variable because the user might cancel the shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes = _
MessageBox.Show("My application", "Do you want to save your work before logging off?", MessageBoxButtons.YesNo)) Then
e.Cancel = True
Else
e.Cancel = False
End If
End If
End Sub
软糖来回答罗:通过System.Diagnostics命名空间下的Process类来关闭程序的进程
Dim 进程集合 = Process.GetProcessesByName("进程名称")
For Each 进程 In 进程集合
进程.Kill()
'进程.Close() '或者使用关闭
Next
也可以先获取所有进程,再来判断这些进程的名称ProcessName
Dim 获取本地所有进程 = Process.GetProcesses()
For Each 进程 In 获取本地所有进程
If 进程.ProcessName = "explorer.exe" Then 进程.Kill()
Next