📄 subject_55030.htm
字号:
<p>
序号:55030 发表者:金申乐 发表日期:2003-10-05 21:09:55
<br>主题:请问如何在Windowsxp下面实现关机语句?
<br>内容:ExitWindowsEx好像不能用在98的方法实现,请问大家应该怎么做,谢谢~~~~~~~
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:iamhere 回复日期:2003-10-05 23:16:16
<br>内容:BOOL ShutdownComputer()<BR>{<BR><BR> HANDLE hToken; <BR> TOKEN_PRIVILEGES tkp; <BR> <BR> if ( ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0) ) <BR> return TRUE;<BR><BR> // Get a token for this process. <BR> if (!OpenProcessToken(GetCurrentProcess(), <BR> TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) <BR> return FALSE;<BR> <BR> // Get the LUID for the shutdown privilege. <BR> <BR> LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, <BR> &tkp.Privileges[0].Luid); <BR> <BR> tkp.PrivilegeCount = 1; // one privilege to set <BR> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; <BR> <BR> // Get the shutdown privilege for this process. <BR> <BR> AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, <BR> (PTOKEN_PRIVILEGES)NULL, 0); <BR> <BR> // Cannot test the return value of AdjustTokenPrivileges. <BR> <BR> if (GetLastError() != ERROR_SUCCESS) <BR> return FALSE;<BR> <BR> // Shut down the system and force all applications to close. <BR> <BR> if (!ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0)) <BR> return FALSE;<BR><BR> return TRUE;<BR><BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -