-
Notifications
You must be signed in to change notification settings - Fork 575
Description
Suggestion
All of the Windows services that I've ever written in C or C++ could be run as a console application for one reason or another.
The windows-services
crate could easily allow this functionality, and already detects if the process was started as a console app:
windows-rs/crates/libs/services/src/lib.rs
Line 132 in 6437f5e
if unsafe { StartServiceCtrlDispatcherW(table.as_ptr()) } == 0 { |
There's more than 1 way to add this feature, but I think that there is 1 way that breaks the least: Add a .allow_console()
(or choose a better name) to Service
that when called allows .run()
to return if the check on the call to StartServiceCtrlDispatcherW()
(linked above) sees that it was run on the console. If the .allow_console()
function is never called, then keep the existing functionaility.
The state in Service
is all private, so adding to it would only affect code in the same file, but a bit in the existing u32
could be used, if that's acceptable.
Please add this functionality, as I can't use it without this feature.