Skip to content

Instantly share code, notes, and snippets.

@aont
Created November 6, 2010 13:53
Show Gist options
  • Select an option

  • Save aont/665438 to your computer and use it in GitHub Desktop.

Select an option

Save aont/665438 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace StandByPreventor
{
class Program
{
static void Main(string[] args)
{
SetThreadExecutionState(ExecutionState.SystemRequired | ExecutionState.Continuous);
}
[DllImport("kernel32.dll")]
extern static ExecutionState SetThreadExecutionState(ExecutionState esFlags);
}
[FlagsAttribute]
public enum ExecutionState : uint
{
// 関数が失敗した時の戻り値
Null = 0,
// スタンバイを抑止
SystemRequired = 1,
// 画面OFFを抑止
DisplayRequired = 2,
// 効果を永続させる。ほかオプションと併用する。
Continuous = 0x80000000,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment