您的位置:寻梦网首页编程乐园VB 编程Visual Basic 电子教程>VB Tips

怎样关闭Windows


使用ExitWindowsEx函数,函数有两个参数确定如何关闭Windows,其中第二个参数未使用
设置为0

Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Declare Function ExitWindowsEx Lib "user32" Alias _
"ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved _
As Long) As Long

If you wanted to forcefully reboot the computer use the following code:
如果想强制重新启动计算机,函数应该这样使用:
t& = ExitWindowsEx(EWX_FORCE OR EWX_REBOOT, 0)