Archived
1
1

Initial commit

This commit is contained in:
Lasse Lauwerys
2025-02-20 16:33:04 +01:00
commit f20cf222a8
36 changed files with 4758 additions and 0 deletions

33
MetroUnlocker/Rebooter.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Runtime.InteropServices;
using System.Management;
namespace MetroUnlocker
{
public class Rebooter
{
public enum RebootMethod
{
LogOff = 0,
PowerOff = 8,
Reboot = 2,
ShutDown = 1,
Suspend = -1,
Hibernate = -2
}
public static void Reboot(RebootMethod method = RebootMethod.Reboot)
{
ManagementClass management = new ManagementClass("Win32_OperatingSystem");
management.Scope.Options.EnablePrivileges = true;
ManagementBaseObject mboShutdownParams = management.GetMethodParameters("Win32Shutdown");
mboShutdownParams["Flags"] = method;
mboShutdownParams["Reserved"] = 0;
management.GetInstances().OfType<ManagementObject>().First().InvokeMethod("Win32Shutdown", mboShutdownParams, null);
}
}
}