|
|
|
|
|
|
Display Windows Services in VB.NET
|
.NET Framework 2.0 provides System.ServiceProcess namespace that contains classes developers can use to create and install Windows Services. These classes include ServiceBase, ServiceInstaller and ServiceProcessInstaller. This namespace also contains one class which can display the list of all the Windows Services running on local or remote computer. In this Tutorial I will show you how you can display the list of locally running Windows Services inVB.NET.
|
|
|
|
You can write following code at Form load even to populate listbox control with all locally running Windows Services. You need to import System.ServiceProcess namespace for the code example below.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Dim localServices As ServiceController() = ServiceController.GetServices() For Each service As ServiceController In localServices listBox1.Items.Add(service.DisplayName) Next End Sub

Write following code at listbox SelectedIndexChanged Event to get information about currently selected Windows Service.
Private Sub listBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Dim localServices As ServiceController() = ServiceController.GetServices() Dim service As ServiceController = localServices(listBox1.SelectedIndex) label4.Text = service.DisplayName label5.Text = service.ServiceName label6.Text = service.Status.ToString() End Sub
|
RELATED TUTORIALS
|
Display Windows Services in C#
How to get Windows installed fonts using .NET
|
|
|
|
|
|
|
|
|
|
|
|
|