极速关机

唉以前看着学校那个“xxx 技术工具”费了好大脑筋都想不出那是怎么搞出来的。

比如那个“一键关机”吧,运行之后连个“正在关机…”都没有了,直接“呼”的一下就关了。怎么做到的?终于找到了……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Option Explicit

Private Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal Newvalue&, ByVal NewThread&, Oldvalue&)
Private Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)

Const SE_SHUTDOWN_PRIVILEGE& = 19
Const SHUTDOWN& = 0
Const RESTART& = 1
Const POWEROFF& = 2

Private Sub LetsShutdown()
RtlAdjustPrivilege& SE_SHUTDOWN_PRIVILEGE&, 1, 0, 0
NtShutdownSystem& SHUTDOWN& Or POWEROFF&
End Sub

是不是很简单?佩服第一个非微软做出这个东西的人!微软在留给我们 ExitWindowsEx 的同时还留了一手……

分享到 评论