新聞中心
vb.net實現(xiàn)關(guān)機(jī)
這是點擊Option 你可以
成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)與策劃設(shè)計,淅川網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:淅川等地區(qū)。淅川做網(wǎng)站價格咨詢:028-86922220
用個msgbox函數(shù) 點擊YES時候運(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ī)
retval = ExitWindowsEx(EWX_SHUTDOWN, 0)
ElseIf Option3.Checked Then
' 重新啟動
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鍵時,結(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
急!VB中實現(xiàn)關(guān)機(jī)(回答正確追分50)
在XP里直接
Function Shutdown(optional Restart =false)
dim c
if restart then c="-r " else c="-s "
c=c "-t 00"
shell "shutdown " c ,vbhide
end function
98好象也可以用
Private Declare Function ExitWindowsEx Lib "USER32" _
(ByVal uFlags As Long, _
ByVal dwReserved As Long _
) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_REBOOT = 2
Private Const EWX_SHUTDOWN = 1
function Shutdown()
ExitWindowsEx(EWX_SHUTDOWN, 0)
end function
function restart()
ExitWindowsEx(EWX_REBOOT, 0)
end function
vb.net WinXP/2000操作系統(tǒng)自動關(guān)機(jī)的實現(xiàn)
Windows
XP的關(guān)機(jī)是由Shutdown.exe程序來控制的,位于Windows\System32文件夾中。如果想讓W(xué)indows
2000也實現(xiàn)同樣的效果,可以把Shutdown.exe復(fù)制到系統(tǒng)目錄下。
比如你的電腦要在22:00關(guān)機(jī),可以選擇“開始→運(yùn)行”,輸入“at
22:00
Shutdown
-s”,這樣,到了22點電腦就會出現(xiàn)“系統(tǒng)關(guān)機(jī)”對話框,默認(rèn)有30秒鐘的倒計時并提示你保存工作。如果你想以倒計時的方式關(guān)機(jī),可以輸入“Shutdown.exe
-s
-t
3600”,這里表示60分鐘后自動關(guān)機(jī),“3600”代表60分鐘。
設(shè)置好自動關(guān)機(jī)后,如果想取消的話,可以在運(yùn)行中輸入“shutdown
-a”。另外輸入“shutdown
-i”,則可以打開設(shè)置自動關(guān)機(jī)對話框,對自動關(guān)機(jī)進(jìn)行設(shè)置。
Shutdown.exe的參數(shù),每個都具有特定的用途,執(zhí)行每一個都會產(chǎn)生不同的效果,比如“-s”就表示關(guān)閉本地計算機(jī),“-a”表示取消關(guān)
機(jī)操作,下面列出了更多參數(shù),大家可以在Shutdown.exe中按需使用。
其他的我也不多說了,這樣說已經(jīng)很詳細(xì)了,你應(yīng)該能看懂。
如何在編的VB.NET程序使用時關(guān)閉電腦
有兩種方法,第一種是調(diào)用shutdown.exe
shell("shutdown.exe路徑
-s
-t
0")
'-t是延遲時間,0表示立刻關(guān)機(jī)
另一種就是使用API了,好像是ExitWindow,你可以去搜索一下其用法。
怎樣才能用VB.NET的代碼來關(guān)閉一個在運(yùn)行的程序
軟糖來回答羅:通過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
文章標(biāo)題:vb.net如何實現(xiàn)關(guān)機(jī)的簡單介紹
標(biāo)題路徑:http://www.dlmjj.cn/article/phgioi.html