
在 Windows 下,有个函数叫 ExitWindowsEx ,可以用来控制系统的锁定、登出、重启和关机。主要就是通过给该函数传入不同的值来执行不同的操作。掌握该函数的使用就能更好的控制你的计算机。
ExitWindowsEx函数原型
1 2 3 4 |
BOOL WINAPI ExitWindowsEx( _In_ UINT uFlags, _In_ DWORD dwReason ); |
传入值和对于功能
EWX_HYBRID_SHUTDOWN(0x00400000)
从 Windows8 开始的混合关机模式。
Beginning with Windows 8: You can prepare the system for a faster startup by combining the EWX_HYBRID_SHUTDOWN flag with the EWX_SHUTDOWN flag.
EWX_LOGOFF(0)
关闭所有进程并注销。
Shuts down all processes running in the logon session of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF(0x00000008)
关闭系统并切断电源,系统支持电源关闭功能。
Shuts down the system and turns off the power. The system must support the power-off feature.
EWX_REBOOT(0x00000002)
关闭系统并重启。
Shuts down the system and then restarts the system.
EWX_RESTARTAPPS(0x00000040)
关闭系统并重启,被注册到重启项的应用将一起重启。
Shuts down the system and then restarts it, as well as any applications that have been registered for restart using the RegisterApplicationRestart function.
EWX_SHUTDOWN(0x00000001)
关闭系统并在安全状态下关闭电源。
Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped.
Continue Reading…