CSDN博客

img xlqin

在98,NT及2000上重新启动机器

发表于2001/7/11 16:24:00  541人阅读

如下是源码,其实在98上只用最后一句ExitWindowEx即可,前面是为了取得权限.

TOKEN_PRIVILEGES tkp,tkpNewButIgnored;
  HANDLE hdlTokenHandle;
  LUID tmpLuid;
  BOOL rc;
  DWORD lBufferNeeded;

  HANDLE  hdlProcessHandle = GetCurrentProcess();
  rc = ::OpenProcessToken(hdlProcessHandle,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,
   &hdlTokenHandle);

  rc = LookupPrivilegeValue("","SeShutdownPrivilege", &tmpLuid);
  tkp.PrivilegeCount = 1; // One privilege to set
  tkp.Privileges[0].Luid = tmpLuid;
  tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  rc = ::AdjustTokenPrivileges(hdlTokenHandle,
   FALSE,
   &tkp,
   sizeof(tkpNewButIgnored),
   &tkpNewButIgnored,
   &lBufferNeeded);

  ExitWindowsEx(EWX_REBOOT,0);

0 0

相关博文

我的热门文章

img
取 消
img