2014-09-28 16:50:33 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2014-05-10 17:28:03 +00:00
|
|
|
|
|
2013-09-25 00:54:51 +00:00
|
|
|
|
namespace MediaBrowser.ServerApplication.Native
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class NativeApp
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class NativeApp
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shutdowns this instance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
MainStartup.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Restarts this instance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void Restart()
|
|
|
|
|
{
|
|
|
|
|
MainStartup.Restart();
|
|
|
|
|
}
|
2013-10-07 14:38:31 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether this instance [can self restart].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
|
|
|
|
|
public static bool CanSelfRestart
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MainStartup.CanSelfRestart;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-07 16:22:19 +00:00
|
|
|
|
|
2014-01-06 01:59:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether [supports automatic run at startup].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
|
|
|
|
|
public static bool SupportsAutoRunAtStartup
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-07 16:22:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance can self update.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
|
|
|
|
|
public static bool CanSelfUpdate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MainStartup.CanSelfUpdate;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-10 17:28:03 +00:00
|
|
|
|
|
|
|
|
|
public static void PreventSystemStandby()
|
|
|
|
|
{
|
|
|
|
|
SystemHelper.ResetStandbyTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal enum EXECUTION_STATE : uint
|
|
|
|
|
{
|
|
|
|
|
ES_NONE = 0,
|
|
|
|
|
ES_SYSTEM_REQUIRED = 0x00000001,
|
|
|
|
|
ES_DISPLAY_REQUIRED = 0x00000002,
|
|
|
|
|
ES_USER_PRESENT = 0x00000004,
|
|
|
|
|
ES_AWAYMODE_REQUIRED = 0x00000040,
|
|
|
|
|
ES_CONTINUOUS = 0x80000000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class SystemHelper
|
|
|
|
|
{
|
|
|
|
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
|
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
|
|
|
|
|
|
|
|
|
|
public static void ResetStandbyTimer()
|
|
|
|
|
{
|
|
|
|
|
EXECUTION_STATE es = SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-25 00:54:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|