Service: --run-service host + registration CLI (install/uninstall/start/stop)

Local checkpoint - NOT for public release.

- RemSoundService (ServiceBase): hosts ServiceSendHost.RunLoop on a worker thread,
  OnStop cancels + joins. Added System.ServiceProcess.ServiceController package.
- ServiceControl: install (sc.exe create, auto-start, careful binPath quoting) /
  uninstall (stop + delete) / start / stop / status. Status query is unprivileged
  (menu can poll it); the mutating verbs self-elevate via ShellExecute runas.
- Program.cs: early guards for --run-service (blocks in the SCM dispatcher) and the
  one-shot elevated verbs, before the single-instance lock (the service is a
  separate role and must never take the interactive lock).
- Self-test "Service registration args" verifies the sc create binPath quoting
  survives a spaced exe path. Gate 20/20.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ednunp
2026-07-12 15:19:01 +01:00
co-authored by Claude Opus 4.8
parent e648bee531
commit 5dbbe4dd71
5 changed files with 270 additions and 0 deletions
+5
View File
@@ -29,6 +29,11 @@
<ProjectReference Include="..\RemSound.Sender\RemSound.Sender.csproj" />
<ProjectReference Include="..\RemSound.Receiver\RemSound.Receiver.csproj" />
<PackageReference Include="NAudio" Version="2.3.0" />
<!-- ServiceBase (to run RemSound.exe as a Windows service under the SCM) and ServiceController
(to query/start/stop the service from the interactive app). Backs the send-only lock-screen
service. Service creation/deletion is done via sc.exe (elevated), which this package doesn't
cover. -->
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.0" />
<!-- LAME wrapper for MP3 encoding. Pulled in for the recording feature. The native
libmp3lame.dll ships with the package and is copied to the output folder. -->
<PackageReference Include="NAudio.Lame" Version="2.1.0" />