A method for shutting down (repost)

zhaozj2021-02-16  86

As seen in the jellyfish, this is a method of direct shutdown, there should be a more easier way, such as call the shell command or kernel32 function?

-------------------------------------------------- -------------------------------------------------- ---

IF ((True == g-> BSYSTIMESHUTDOWN) && (st.WHOUR == g-> systemshutdown.whour)

&& ((st.wminute == g-> systemshutdown.wminute))))))))))))))))))))).

// get version info to determine operation osversioninfo osvi; osvi.dwosveionsInfosize = sizeof (osversioninfo); if (getVersionex (& OSVI) == 0) Return False;

// Determine the platform if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {// Windows NT 3.51, Windows NT 4.0, Windows 2000, // Windows XP, or Windows .NET Server if (OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES |! TOKEN_QUERY , & htokeen) Return False;

Lookuppprivilegevalue (NULL, SE_SHUTDOWN_NAME, & TKP.PRIVILEGES [0] .luid);

Tkp.privilegect = 1; // One privilege to set tkp.privileges [0] .attributes = se_privilege_enabled;

AdjustTokenPrivileges (HToken, False, & Tkp, 0, (ptoken_privileges) null, 0);}

:: EXITWINDOWSEX (EWX_SHUTDOWN | EWX_Poweroff, 0);

}

转载请注明原文地址:https://www.9cbs.com/read-12649.html

New Post(0)