Add a description to the Windows service

xiaoxiao2021-03-05  22

Recently wrote a Windows Services (Windows Services), after installation, feel different from the existing Windows service. why? My lack of description, the middle column is empty.

Look at the .NET's ServiceBase class does not add a description of the description.

Public Class ProjectInstaller: There is no property in system.configuration.install.Installer to add. After searching for the network, you know to overload ProjectInstaller's install and uninstall virtual methods. In fact, rewriting these virtual methods is to add a key value "Description" in the registry corresponding service, and its value fills the corresponding description.

Public override void install (iDictionary stateserver) {microsoft.win32.registryKey System, Service, Config

try {// Let the project installer do its job base.Install (stateServer); system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey ( "System") OpenSubKey ( "CurrentControlSet") OpenSubKey ( "Services");.. service = System.opensubKey (this.serviceInstaller1.ServiceName, true); Service.SetValue ("Description", "Services Description");

// Add additional key config = service.createSubkey ("additionalinformation");} catch (exception e) {

}} Public override void uninstall (iDictionary stateserver) {Microsoft.Win32.RegistryKey System, CurrentControlset, Services, Service;

try {system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey ( "System"); currentControlSet = system.OpenSubKey ( "CurrentControlSet"); services = currentControlSet.OpenSubKey ( "Services"); service = services.OpenSubKey (this.serviceInstaller1 .ServiceName, True); // Delete additional keys service.deleteSubkeytree ("additionalinformation"); // ...} catch (exception e) {} finally {base.unInstall (stateserver);}}

Note that these codes are in the ProjectInstaller file.

Maybe there is a better way, I hope everyone will advise.

转载请注明原文地址:https://www.9cbs.com/read-36429.html

New Post(0)