Я посмотрел и не мог найти, что должно быть простым вопросом:
Как служба Windows может определить имя службы, для которой она была запущена?
Я знаю, что установка может взломать реестр и добавить аргумент командной строки, но логически кажется, что это должно быть ненужным, поэтому этот вопрос.
Я надеюсь запустить несколько копий одного двоичного файла более чисто, чем взломать реестр.
Edit
Это написано на С#. Моя точка входа в приложение Main() делает разные вещи, в зависимости от аргументы командной строки:
- Установить или удалить службу. Командная строка может предоставлять нестандартные ServiceName и может изменять количество рабочих потоков.
- Запуск в качестве исполняемого файла командной строки (для отладки),
- Запуск в качестве "Службы Windows". Здесь он создает экземпляр моей производной от ServiceBase класс, затем вызывает System.ServiceProcess.ServiceBase.Run(экземпляр);
В настоящее время шаг установки добавляет имя службы и количество потоков в ImagePath в реестре, чтобы приложение могло определить это имя службы.