快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb点虐 阻止关机 vbs取消关机代码

vb点虐 2008拦截关机或注销消息

在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点虐 WinXP/2000操作系统自动关机的实现

Windows

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实现关机和重新启动

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 注销当前用户retval = ExitWindowsEx(EWX_FORCE )ElseIf Option Checked Then 关闭计算机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键时 结束应用程序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函数来达到关机和重新启动的目的 在ExitWindowEx()函数中 参数uFlags指定要进行何种操作 在表 中列出了参数uFlags的值及其说明 表  参数uFlags的值及说明 lishixinzhi/Article/program/net/201311/13585

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

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

shell("shutdown.exe路径

-s

-t

0")

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

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


当前文章:vb点虐 阻止关机 vbs取消关机代码
文章来源:http://www.6mz.cn/article/ddjeogi.html

其他资讯