[摘要]EWX_FORCE; if (ExitWindowsEx(how, 0) == 0) throw new PrivilegeException(FormatError(Marshal.Ge...
EWX_FORCE;
if (ExitWindowsEx(how, 0) == 0)
throw new PrivilegeException(FormatError(Marshal.GetLastWin32Error()));
}
/// <summary>
/// Tries to enable the specified privilege.
/// </summary>
/// <param name="privilege">The privilege to enable.</param>
/// <exception cref="PrivilegeException">There was an error while requesting a required privilege.</exception>
protected static void EnableToken(string privilege ) {
if (!CheckEntryPoint("advapi32.dll", "AdjustTokenPrivileges"))
return;
IntPtr tokenHandle = IntPtr.Zero;
LUID privilegeLUID = new LUID();
TOKEN_PRIVILEGES newPrivileges = new TOKEN_PRIVILEGES();
TOKEN_PRIVILEGES tokenPrivileges ;
if (OpenProcessToken(Process.GetCurrentProcess().Handle, TOKEN_ADJUST_PRIVILEGES
关键词:运用C#编写的一个定时关机程序