ソリューションは、コメントを通じて指摘されているが、私はウェブ検索を経由して到着した他の誰のための簡単なスターターソリューションを提供しています:
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
public App()
{
InitializeComponent();
App.Current.Startup += new StartupEventHandler((sender, e) =>
{
SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
});
App.Current.Exit += new ExitEventHandler((sender, e) =>
{
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
});
}
}
[FlagsAttribute]
public enum EXECUTION_STATE : uint
{
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001
// Legacy flag, should not be used.
// ES_USER_PRESENT = 0x00000004
}
内にあるロジックを置くための代替場所をメインアプリケーションウィンドウのStateChanged
のイベントハンドラ:
this.StateChanged += new EventHandler((sender, e) =>
{
if (WindowState == System.Windows.WindowState.Maximized)
{
SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
}
else
{
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
});
あなたは、Win32を探している[ 'SetThreadExecutionState()'関数](http://msdn.microsoft.com/en-us/library/windows/デスクトップ/ aa373208.aspx)。しかし、よりよい解決策はグループポリシーです。 –
ああ、素晴らしい!それを回答として投稿できますか? –
また、これをリンクとして追加することもできます。http://pinvoke.net/default.aspx/kernel32.SetThreadExecutionState –