下面的代碼是如何工作的?它給出了我想要的答案。但我想知道它是如何工作的?這是如何工作的?它給出了答案,但我不理解它。
public static void ShutDownComputer()
{
ManagementBaseObject outParameter = null;
ManagementClass sysOs = new ManagementClass("Win32_OperatingSystem");
sysOs.Get();
sysOs.Scope.Options.EnablePrivileges = true;
ManagementBaseObject inParameter = sysOs.GetMethodParameters("Win32Shutdown");
inParameter["Flags"] = "8";
inParameter["Reserved"] = "0";
foreach (ManagementObject maObj in sysOs.GetInstances())
{
outParameter = maObj.InvokeMethod("Win32Shutdown", inParameter, null);
}
}