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

    技术2022-05-11  108

    如下是源码,其实在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)