How to find the "Display Name" of a service in .net?

I have a service that runs on the system in multiple instances. I need to find DISPLAY_NAMEservices from the service. I tried ServiceBase.ServiceName, but it returns (possibly) the name of the service from the project installer, which is at least in this case useless.

The service is installed installutilwith the parameter /name=.

Edit

I have a workaround based on the answer of Imran Balush. I read the name in the installer Me.Context.Parameters("name")and write it in the registry subkey ImagePathand read it using the Environment.GetCommandLineArgs service in the service.

+5
source share
2 answers

ProjectInstaller Windows? , ProjectInstaller, ServiceInstaller , ServiceInstaller . - Display Name InitializeComponent ProjectInstaller.Designer.cs ProjectInstaller.Designer.vb, :

this.yourServiceInstaller.DisplayName = "Service Display Name";
+4

ServiceName, ServiceController:

ServiceController sc = new ServiceController(this.ServiceName);
var displayName = sc.DisplayName;

, ServiceName, , ServiceBase. , , .

+2

All Articles