vb點虐 禁止關(guān)機 vbs關(guān)閉程序的代碼

vb點虐 2008攔截關(guān)機或注銷消息

在SystemEvents類中 可以 用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。 (當(dāng)用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。當(dāng)用戶試圖注銷或關(guān)閉系統(tǒng)時發(fā)生。) 這個 事件處理函數(shù)中 可以找到如下方法

在鄧州等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、做網(wǎng)站 網(wǎng)站設(shè)計制作按需定制設(shè)計,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),成都全網(wǎng)營銷推廣,成都外貿(mào)網(wǎng)站建設(shè)公司,鄧州網(wǎng)站建設(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

怎樣用vbs命令禁止關(guān)機

代碼如下,復(fù)制到記事本保存,然后修改文件名后綴為.reg,然后雙擊運行

(或者復(fù)制到記事本另存為文件類型選“所有文件”,文件名填“xx.reg”)

Windows?Registry?Editor?Version?5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]

"noclose"=dword:01

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System]

"DisableCMD"=dword:02

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]

"DisableTaskMgr"=dword:01

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]??

"NoViewContextMenu"=dword:01

"NoTrayContextMenu"=dword:01

"NoChangeStartMenu"=dword:01

代碼解釋:

第一段是固定聲明,下面空一行

第二段是禁關(guān)機重啟

第三段是禁cmd

第四段是禁任務(wù)管理器

第五段是禁右鍵

如果要徹底封殺的話,還應(yīng)該禁止注冊表和組策略以及vbs等,附禁止代碼列表:

如何在編的VB.NET程序使用時關(guān)閉電腦

有兩種方法,第一種是調(diào)用shutdown.exe

shell("shutdown.exe路徑

-s

-t

0")

'-t是延遲時間,0表示立刻關(guān)機

另一種就是使用API了,好像是ExitWindow,你可以去搜索一下其用法。

小技巧:VB.NET實現(xiàn)關(guān)機和重新啟動

Private Declare Function ExitWindowsEx Lib user (ByVal uFlags As Integer ByVal dwReserved As Integer) As IntegerConst EWX_FORCE As Short = Const EWX_LOGOFF As Short = Const EWX_REBOOT As Short = Const EWX_SHUTDOWN As Short = Dim retval As Integer 定義Esc按鍵Const VK_ESCAPE As Short = H BsPrivate Sub Command _Click(ByVal eventSender As System Object ByVal eventArgs As System EventArgs) Handles Command ClickIf Option Checked Then 注銷當(dāng)前用戶retval = ExitWindowsEx(EWX_FORCE )ElseIf Option Checked Then 關(guān)閉計算機retval = ExitWindowsEx(EWX_SHUTDOWN )ElseIf Option Checked Then 重新啟動retval = ExitWindowsEx(EWX_REBOOT )End IfEnd SubPrivate Sub Command _Click(ByVal eventSender As System Object ByVal eventArgs As System EventArgs) Handles Command ClickMe Close()End Sub 按Esc鍵時 結(jié)束應(yīng)用程序Private Sub Form _KeyPress(ByVal eventSender As System Object ByVal eventArgs As System Windows Forms KeyPressEventArgs) Handles MyBase KeyPressDim KeyAscii As Short = Asc(eventArgs KeyChar)If KeyAscii = VK_ESCAPE ThenMe Close()End IfIf KeyAscii = TheneventArgs Handled = TrueEnd IfEnd Sub本實例通過使用ExitWindowEx()API函數(shù)來達到關(guān)機和重新啟動的目的 在ExitWindowEx()函數(shù)中 參數(shù)uFlags指定要進行何種操作 在表 中列出了參數(shù)uFlags的值及其說明 表  參數(shù)uFlags的值及說明 lishixinzhi/Article/program/net/201311/13585

當(dāng)前文章:vb點虐 禁止關(guān)機 vbs關(guān)閉程序的代碼
網(wǎng)頁地址:http://www.muchs.cn/article28/ddijjcp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、建站公司服務(wù)器托管、App設(shè)計、靜態(tài)網(wǎng)站、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司