這是點(diǎn)擊Option 你可以
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、肥鄉(xiāng)網(wǎng)絡(luò)推廣、小程序開(kāi)發(fā)、肥鄉(xiāng)網(wǎng)絡(luò)營(yíng)銷、肥鄉(xiāng)企業(yè)策劃、肥鄉(xiāng)品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供肥鄉(xiāng)建站搭建服務(wù),24小時(shí)服務(wù)熱線:18982081108,官方網(wǎng)址:www.cdcxhl.com
用個(gè)msgbox函數(shù) 點(diǎn)擊YES時(shí)候運(yùn)行關(guān)機(jī)代碼即可
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer
Const EWX_FORCE As Short = 4
Const EWX_LOGOFF As Short = 0
Const EWX_REBOOT As Short = 2
Const EWX_SHUTDOWN As Short = 1
Dim retval As Integer
' 定義Esc按鍵
Const VK_ESCAPE As Short = H1Bs
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
If Option1.Checked Then
' 注銷當(dāng)前用戶
retval = ExitWindowsEx(EWX_FORCE, 0) bitsCN.Com
ElseIf Option2.Checked Then
' 關(guān)閉計(jì)算機(jī)
retval = ExitWindowsEx(EWX_SHUTDOWN, 0)
ElseIf Option3.Checked Then
' 重新啟動(dòng)
retval = ExitWindowsEx(EWX_REBOOT, 0)
End If
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
Me.Close()
End Sub
' 按Esc鍵時(shí),結(jié)束應(yīng)用程序
Private Sub Form1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
If KeyAscii = VK_ESCAPE Then BBS.bitsCN.com網(wǎng)管論壇
Me.Close()
End If
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
軟糖來(lái)回答羅:通過(guò)System.Diagnostics命名空間下的Process類來(lái)關(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)程,再來(lái)判斷這些進(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
有兩種方法,第一種是調(diào)用shutdown.exe
shell("shutdown.exe路徑 -s -t 0") '-t是延遲時(shí)間,0表示立刻關(guān)機(jī)
另一種就是使用API了,好像是ExitWindow,你可以去搜索一下其用法。