VB中如何实现系统的关机、重启和注销
VB版本:VB6.0中文企业版系统:WinXP简体中文SP2如何用VB实现系统的关机、重启和注销大虾帮忙……...
VB版本:VB6.0中文企业版 系统:WinXP简体中文SP2
如何用VB实现系统的关机、重启和注销
大虾帮忙…… 展开
如何用VB实现系统的关机、重启和注销
大虾帮忙…… 展开
1个回答
展开全部
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)
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
Me.Close()
End If
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
常量名
值
说明
EWX_FORCE
4
终止所有进程,包括没有响应的进程,并注销Windows
EWX_REBOOT
2
重新启动系统
EWX_SHUTDOWN
1
关闭系统
EWX_LOGOFF
0
终止所有正在运行的进程,并注销Windows
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)
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
Me.Close()
End If
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
常量名
值
说明
EWX_FORCE
4
终止所有进程,包括没有响应的进程,并注销Windows
EWX_REBOOT
2
重新启动系统
EWX_SHUTDOWN
1
关闭系统
EWX_LOGOFF
0
终止所有正在运行的进程,并注销Windows
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询