网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb.net防止关机的简单介绍

vb.net WinXP/2000操作系统自动关机的实现

Windows

创新互联从2013年开始,先为如皋等服务建站,如皋等地企业,进行企业商务咨询服务。为如皋企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

XP的关机是由Shutdown.exe程序来控制的,位于Windows\System32文件夹中。如果想让Windows

2000也实现同样的效果,可以把Shutdown.exe复制到系统目录下。

比如你的电脑要在22:00关机,可以选择“开始→运行”,输入“at

22:00

Shutdown

-s”,这样,到了22点电脑就会出现“系统关机”对话框,默认有30秒钟的倒计时并提示你保存工作。如果你想以倒计时的方式关机,可以输入“Shutdown.exe

-s

-t

3600”,这里表示60分钟后自动关机,“3600”代表60分钟。

设置好自动关机后,如果想取消的话,可以在运行中输入“shutdown

-a”。另外输入“shutdown

-i”,则可以打开设置自动关机对话框,对自动关机进行设置。

Shutdown.exe的参数,每个都具有特定的用途,执行每一个都会产生不同的效果,比如“-s”就表示关闭本地计算机,“-a”表示取消关

机操作,下面列出了更多参数,大家可以在Shutdown.exe中按需使用。

其他的我也不多说了,这样说已经很详细了,你应该能看懂。

vb.net实现关机

这是点击Option 你可以

用个msgbox函数 点击YES时候运行关机代码即可

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

' 注销当前用户

retval = ExitWindowsEx(EWX_FORCE, 0) bitsCN.Com

ElseIf Option2.Checked Then

' 关闭计算机

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键时,结束应用程序

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网管论坛

Me.Close()

End If

If KeyAscii = 0 Then

eventArgs.Handled = True

End If

End Sub

怎样用vbs命令禁止关机

代码如下,复制到记事本保存,然后修改文件名后缀为.reg,然后双击运行

(或者复制到记事本另存为文件类型选“所有文件”,文件名填“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

代码解释:

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

第二段是禁关机重启

第三段是禁cmd

第四段是禁任务管理器

第五段是禁右键

如果要彻底封杀的话,还应该禁止注册表和组策略以及vbs等,附禁止代码列表:

vb.net2008拦截关机或注销消息

在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

如何在编的VB.NET程序使用时关闭电脑

有两种方法,第一种是调用shutdown.exe

shell("shutdown.exe路径

-s

-t

0")

'-t是延迟时间,0表示立刻关机

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


新闻名称:vb.net防止关机的简单介绍
文章转载:http://bjjierui.cn/article/hsegse.html

其他资讯