强制关闭计算机.net -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    用API函数Exit Windows Ex可以实现强制关机,即便是您的应用程序尚未保存文件 Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Const EWX_SHU TD WN = 1 Const EWX_LOGOFF = 0 Const EWX_R

    用API函数ExitWindowsEx可以实现强制关机,即便是您的应用程序尚未保存文件

    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

    Const EWX_SHUTDOWN = 1

    Const EWX_LOGOFF = 0

    Const EWX_REBOOT = 2

    Const EWX_FORCE = 4

    Private Sub Command1_Click()

    Dim a

    a = ExitWindowsEx(EWX_LOGOFF or EWX_FORCE or EWX_SHUTDOWN, 0)

    End Sub

    如果将

    a = ExitWindowsEx(EWX_LOGOFF or EWX_FORCE or EWX_SHUTDOWN, 0)

    改换为

    a = ExitWindowsEx(EWX_LOGOFF or EWX_REBOOT, 0)

    即可实现强制重启计算机

    原文转自:http://www.ltesting.net

最新文章