첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

728x90
반응형
728x170
using System.Management;

ManagementClass managementClass = new ManagementClass("Win32_OperatingSystem");

managementClass.Get();

managementClass.Scope.Options.EnablePrivileges = true;

ManagementBaseObject shutdownParameterManagementBaseObject = managementClass.GetMethodParameters("Win32Shotdown");

shutdownParameterManagementBaseObject["Flags"   ] = "1";
shutdownParameterManagementBaseObject["Reserved"] = "0";

ManagementBaseObject shutdownManagementBaseObject = null;

foreach(ManagementObject managementObject in managementClass.GetInstances())
{
    shutdownManagementBaseObject = managementObject.InvokeMethod("Win32Shutdown", shutdownParameterManagementBaseObject, null);
}

※ System.Management 참조를 추가한다.

728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요