360教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

运用C#编写的一个定时关机程序

时间:2024/7/17作者:未知来源:360教程人气:

[摘要]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#编写的一个定时关机程序




Copyright © 2012-2018 360教程(http://www.360sd.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版