📄 readme.wzd
字号:
/////////////////////////////////////////////////////////////////////
// NT Privileges...
/////////////////////////////////////////////////////////////////////
// 1) To reboot an NT machine, you must give your application a shutdown
// privilege:
static HANDLE hToken;
static TOKEN_PRIVILEGES tp;
static LUID luid;
if (::OpenProcessToken( GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ))
{
::LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &luid );
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
::AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL );
}
// Add this even if your application will also be running on other systems.
/////////////////////////////////////////////////////////////////////
// Local reboot...
/////////////////////////////////////////////////////////////////////
// 1) Use ExitWindowEx():
::ExitWindowsEx(
// EWX_LOGOFF //logs user off
// EWX_SHUTDOWN //shuts down system
EWX_REBOOT //reboots system
// EWX_POWEROFF //shuts down and turns system off (if system has power-off feature)
// |EWX_FORCE //forces processes to terminate--use only in emergency
,0 //reserved
);
/////////////////////////////////////////////////////////////////////
// Remote reboot...
/////////////////////////////////////////////////////////////////////
// 1) To reboot a machine over the network:
::InitiateSystemShutdown(
"\\\\OtherMachine", // computer to shut down--NULL== local system
"Goodbye!", // a message to user
60, // time to display message in seconds
FALSE, // TRUE == force processes to terminate
TRUE // TRUE == reboot after shutdown
);
// 2) To cancel this reboot:
::AbortSystemShutdown(
"\\\\OtherMachine" // computer NOT to shut down--NULL== local system
);
/////////////////////////////////////////////////////////////////////
// From: Visual C++ MFC Programming by Example by John E. Swanke
// Copyright (C) 1999 jeswanke. All rights reserved.
/////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -