关闭系统(70分)

  • 主题发起人 主题发起人 hsw
  • 开始时间 开始时间
H

hsw

Unregistered / Unconfirmed
GUEST, unregistred user!
关闭系统时,有一个‘AdjustTokenPrivileges’(关闭令牌特权)的API function 的各参数<br>是任何设置的?<br>BOOL AdjustTokenPrivileges(<br><br>&nbsp; &nbsp; HANDLE &nbsp;TokenHandle, // handle of token that contains privileges<br>&nbsp; &nbsp; BOOL &nbsp;DisableAllPrivileges, // flag for disabling all privileges<br>&nbsp; &nbsp; PTOKEN_PRIVILEGES &nbsp;NewState, // address of new privilege information<br>&nbsp; &nbsp; DWORD &nbsp;BufferLength, // size of previous information buffer<br>&nbsp; &nbsp; PTOKEN_PRIVILEGES &nbsp;PreviousState, // address of previous information<br>&nbsp; &nbsp; PDWORD &nbsp;ReturnLength // address of required buffer size<br>&nbsp; &nbsp;);
 
delphi帮助里不是都有吗?
 
有无例子说明,如TokenHandle(令牌句柄)是什么意思?<br>Cakk 的回答太.......望各位大虾指点!<br>谢谢。<br>hsw
 
it is not nessary by default under both NT and win9x.
 
BOOL ShutdownNT()<br>{<br> PHANDLE lpMyToken = new HANDLE;<br> PTOKEN_PRIVILEGES lpNewToken = new TOKEN_PRIVILEGES;<br> LUID Luid;<br> HANDLE hProcess = GetCurrentProcess();<br><br> if (!hProcess)<br>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE;<br><br> if (!OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, lpMyToken))<br>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE;<br><br> if (!LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &amp;Luid))<br> return FALSE;<br><br> lpNewToken-&gt;PrivilegeCount = 1;<br> lpNewToken-&gt;Privileges[0].Luid = Luid;<br> lpNewToken-&gt;Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br><br> if (!AdjustTokenPrivileges(*lpMyToken, FALSE, lpNewToken, NULL, NULL, NULL))<br>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE;<br> return ExitWindowsEx(EWX_SHUTDOWN, NULL);<br>}<br>
 
谢谢大家!<br>
 
后退
顶部