이 게시물은 cpr1993에 의해 2019-1-9 11:02에 마지막으로 편집되었습니다.
먼저, using 문장을 사용해 필요한 네임스페이스를 추가하세요:사용 시스템.진단; 사용 System.Runtime.InteropServices;
폐쇄 Process.Start("shutdown","/s /t 0"); 매개변수 /s는 컴퓨터를 종료한다는 뜻입니다매개변수 /t 0은 0초 후에 컴퓨터가 명령을 실행하도록 지시하는 것을 의미합니다
재시작 Process.Start("shutdown", "/r /t 0"); 매개변수 /r은 컴퓨터를 재시작한다는 뜻입니다
취소
클래스에서 DllImport를 사용해 Windows API 함수를 선언해야 합니다: [DllImport("user32")] 공공 정적 외부 불 ExitWindowsEx(uint uFlags, uint dwReason);
그 다음, 다음 코드를 사용해 로그아웃할 수 있습니다:
ExitWindowsEx(0,0);
잠금장치로그아웃과 마찬가지로 함수를 선언해야 합니다: [DllImport("user32")] 공공 정적 외부 공허 LockWorkStation();
그 다음, 다음 코드를 사용해 잠금을 달성할 수 있습니다:
LockWorkStation();
휴면과 수면
다시 말하지만, 함수를 선언해야 합니다: [DllImport("PowrProf.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent);
다음 코드로 최대 절전 모드를 구현하세요: SetSuspendState(true, true, true);
수면을 달성하기 위한 코드는 다음과 같습니다: SetSuspendState(false, true, true);
|