halo fren nih, tutor dari gw untuk bikin kompi lo shutdown klo mo dikembangin silakan...bagus banget getoo lo...
jangan sembarang dicoba ya ntar binun lagi he..he...
#define SHTDN_REASON_MAJOR_SYSTEM 0x00050000 // ripped from reason.h
#define SHTDN_REASON_MINOR_HUNG 0x00000005
#define SHUTDOWN_SYSTEM_HUNG (SHTDN_REASON_MAJOR_SYSTEM|SHTDN_REASON_MINOR_HUNG) // for XP,2k only ignored on 9x
#define EWX_SYSTEM_REBOOT (EWX_REBOOT | EWX_FORCE)
#define EWX_FORCE_SHUTDOWN (EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCE)
void Reboot(void)
{
// privelages needed for nt,2k,xp
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// get a token for this process.
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
// get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
// kill explorer to prevent hangup on 9x, maybe ME, dunno about 2k,XP
KillProcess("Explorer.exe");
// reboot/shutdown this bitch
if ( !ExitWindowsEx(EWX_SYSTEM_REBOOT /* or EWX_FORCE_SHUTDOWN */, SHUTDOWN_SYSTEM_HUNG) )
{
// failed
ExitProcess(0);
}
}
klo da yang salah mohon dikoreksi toh, thanks u ....
Tidak ada komentar:
Posting Komentar