-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinAPI.cs
29 lines (26 loc) · 837 Bytes
/
WinAPI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Runtime.InteropServices;
namespace MusicBeePlugin
{
[Flags]
public enum EXECUTION_STATE : uint
{
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001
}
public static class WinAPI
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern uint SetThreadExecutionState(EXECUTION_STATE esFlags);
public static void PreventMonitorPowerdown()
{
SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
}
public static void AllowMonitorPowerdown()
{
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
}
}