Make `<delayedAutoStart>`/`<beeponshutdown>`/`<interactive>` a boolean

pull/614/head
NextTurn 2020-07-29 00:00:00 +08:00 committed by Next Turn
parent 4d187eb882
commit ddab4150ac
4 changed files with 15 additions and 7 deletions

View File

@ -180,7 +180,7 @@ SECTION: Service management
Enables the Delayed Automatic Start if 'Automatic' is specified in the 'startmode' field.
See the WinSW documentation to get info about supported platform versions and limitations.
-->
<!--<delayedAutoStart/>-->
<!--<delayedAutoStart>true</delayedAutoStart>-->
<!--
OPTION: depend
@ -196,7 +196,7 @@ SECTION: Service management
Indicates the service can interactwith the desktop.
-->
<!--
<interactive/>
<interactive>true</interactive>
-->
<!--
@ -281,7 +281,7 @@ SECTION: Other options
Indicates the service should beep when finished on shutdown (if it's supported by OS).
-->
<!--
<beeponshutdown/>
<beeponshutdown>true</beeponshutdown>
-->
<!--

View File

@ -31,6 +31,9 @@ namespace WinSW.Native
[DllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ChangeServiceConfig2W")]
internal static extern bool ChangeServiceConfig2(IntPtr serviceHandle, ServiceConfigInfoLevels infoLevel, in SERVICE_DELAYED_AUTO_START_INFO info);
[DllImport(Libraries.Advapi32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ChangeServiceConfig2W")]
internal static extern bool ChangeServiceConfig2(IntPtr serviceHandle, ServiceConfigInfoLevels infoLevel, in SERVICE_PRESHUTDOWN_INFO info);
[DllImport(Libraries.Advapi32)]
internal static extern bool CloseServiceHandle(IntPtr objectHandle);
@ -164,6 +167,11 @@ namespace WinSW.Native
public unsafe SC_ACTION* Actions;
}
internal struct SERVICE_PRESHUTDOWN_INFO
{
public int PreshutdownTimeout;
}
internal struct SERVICE_STATUS
{
public ServiceType ServiceType;

View File

@ -572,18 +572,18 @@ namespace WinSW
/// True if the service should be installed with the DelayedAutoStart flag.
/// This setting will be applyed only during the install command and only when the Automatic start mode is configured.
/// </summary>
public bool DelayedAutoStart => this.dom.SelectSingleNode("//delayedAutoStart") != null;
public bool DelayedAutoStart => this.SingleBoolElement("delayedAutoStart", Defaults.DelayedAutoStart);
/// <summary>
/// True if the service should beep when finished on shutdown.
/// This doesn't work on some OSes. See http://msdn.microsoft.com/en-us/library/ms679277%28VS.85%29.aspx
/// </summary>
public bool BeepOnShutdown => this.dom.SelectSingleNode("//beeponshutdown") != null;
public bool BeepOnShutdown => this.SingleBoolElement("beeponshutdown", Defaults.DelayedAutoStart);
/// <summary>
/// True if the service can interact with the desktop.
/// </summary>
public bool Interactive => this.dom.SelectSingleNode("//interactive") != null;
public bool Interactive => this.SingleBoolElement("interactive", Defaults.DelayedAutoStart);
/// <summary>
/// Environment variable overrides

View File

@ -171,7 +171,7 @@ namespace WinSW.Tests.Util
public ConfigXmlBuilder WithDelayedAutoStart()
{
return this.WithRawEntry("<delayedAutoStart/>");
return this.WithRawEntry("<delayedAutoStart>true</delayedAutoStart>");
}
}
}