Tuesday, May 16, 2006

At work we are currently developing a Windows Service, I noticed that when you install the service using the InstallUtil it doesn’t set a service description for you.

To add one add the following code to your ProjectInstaller class (this is created by clicking “Add Installer” in your windows service design view) just under the InitializeComponent method:

Public Overrides Sub Install(ByVal stateServer As IDictionary)

         MyBase.Install(stateServer)

         Me.AddServiceDescription()

End Sub

 

Public Sub AddServiceDescription()

         Dim service As RegistryKey = Registry.LocalMachine.OpenSubKey("System").OpenSubKey("CurrentControlSet").OpenSubKey("Services").OpenSubKey(Me.ServiceInstaller1.ServiceName, True)

         service.SetValue("Description", "My service description.")

End Sub

This block of code will go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourWindowsService and create a service description key for you based on your service name.

Tuesday, May 16, 2006 9:26:59 PM (GMT Standard Time, UTC+00:00)  #    Comments [1]  | 
Wednesday, May 17, 2006 3:12:39 PM (GMT Standard Time, UTC+00:00)
Thx! I will put it in my service
sy
Comments are closed.

Theme design by Jelle Druyts

Pick a theme: