Show the Service menu on all Windows (let Win7 try the service)

Removes the Windows-10+ version gate on the Service menu so a Win7 user can
actually attempt Install/Configure and we can see whether the service works
there. Still launch-safe: building the menu references no service type (inlined
const verbs + method-group handlers), so System.ServiceProcess is not loaded at
window construction on any OS — verified by the 'main window builds without
loading the service assembly' self-test and an empirical 0-modules launch check.
The assembly loads only when the menu is opened (status query) or an action runs,
both try/catch-wrapped, so on Win7 it degrades to 'status unavailable' rather
than crashing. Re-gate with IsWindowsVersionAtLeast(10,0) if Win7 can't run it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ednunp
2026-07-15 18:59:11 +01:00
co-authored by Claude Opus 4.8
parent 5fa88aba5c
commit 4d1815e071
+10 -11
View File
@@ -2182,17 +2182,16 @@ public sealed class MainForm : Form
// and the arrow keys.
menu.Items.Add(fileMenu);
menu.Items.Add(recordMenu);
// Offer the Service menu on Windows 10+ only. This is a VERSION check on purpose, not a runtime
// probe: a probe would have to construct a ServiceController to test it, which loads
// System.ServiceProcess — the exact assembly that won't load on Windows 7 — during window
// construction on EVERY launch. Deciding by version is free (it touches no service type), so on
// Windows 7/8 the menu is simply hidden and that assembly is never referenced at launch at all,
// which is what keeps the app launching there. On Windows 10+ the assembly loads only later, if the
// user actually opens the Service menu (the DropDownOpening handler, wrapped in try/catch). Feature-
// detecting on Win7 and keeping Win7 launch-safe are mutually exclusive — you can't test whether the
// assembly loads without loading it — so we choose guaranteed launch safety.
if (OperatingSystem.IsWindowsVersionAtLeast(10, 0))
menu.Items.Add(BuildServiceMenu());
// The Service menu is shown on EVERY Windows now (2026-07-14) so a Win7 user can actually try it —
// we don't yet know whether the service works there, and the only way to find out is to let it try.
// This is launch-safe: BUILDING the menu references no service type (the verb strings are inlined
// consts and the handlers are method-group lambdas), so System.ServiceProcess is NOT loaded at
// window construction on any OS — proven by the "main window builds without loading the service
// assembly" self-test. That assembly loads only when the user OPENS the menu (the DropDownOpening
// status query) or runs an action, both of which are wrapped in try/catch, so if it can't load on
// Win7 the menu degrades to "status unavailable" instead of crashing. If Win7 turns out unable to
// run the service, re-gate this with OperatingSystem.IsWindowsVersionAtLeast(10, 0).
menu.Items.Add(BuildServiceMenu());
menu.Items.Add(optionsMenu);
menu.Items.Add(helpMenu);
return menu;