添加托盤圖標(biāo)控件,并設(shè)置好其Icon屬性,然后添加如下代碼:
在阿魯科爾沁等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計、網(wǎng)站制作 網(wǎng)站設(shè)計制作按需制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),網(wǎng)絡(luò)營銷推廣,外貿(mào)網(wǎng)站制作,阿魯科爾沁網(wǎng)站建設(shè)費(fèi)用合理。
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub
在SystemEvents類中 可以 用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。 (當(dāng)用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。當(dāng)用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。) 這個 事件處理函數(shù)中 可以找到如下方法
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類來關(guān)閉程序的進(jìn)程
Dim?進(jìn)程集合?=?Process.GetProcessesByName("進(jìn)程名稱")
For?Each?進(jìn)程?In?進(jìn)程集合
進(jìn)程.Kill()
'進(jìn)程.Close()?'或者使用關(guān)閉
Next
也可以先獲取所有進(jìn)程,再來判斷這些進(jìn)程的名稱ProcessName
Dim?獲取本地所有進(jìn)程?=?Process.GetProcesses()
For?Each?進(jìn)程?In?獲取本地所有進(jìn)程
If?進(jìn)程.ProcessName?=?"explorer.exe"?Then?進(jìn)程.Kill()
Next