Hi,
I am using visual basic 2010 express for the past three days, and I am trying a few things out
I am using this to start a service
And this to stop a service
I also added a progress bar, but after doing a lot of reading, I just can’t find the correct way of making it grow to 100% full when the service starts and empty again, and the same when the service stops.
Help?
I am using visual basic 2010 express for the past three days, and I am trying a few things out
I am using this to start a service
VB.NET:
Private Sub StartService_Click(sender As System.Object, e As System.EventArgs) Handles StartService.Click
Dim sc As New ServiceController("helpsvc")
If sc.Status = ServiceControllerStatus.Running Then
MessageBox.Show("Service is already running")
Exit Sub
End If
sc.Start()
sc.WaitForStatus(ServiceControllerStatus.Running)
LabelStatus.Text = sc.Status.ToString
greenpic.Visible = True
redpic.Visible = False
End Sub
And this to stop a service
VB.NET:
Private Sub StopService_Click(sender As System.Object, e As System.EventArgs) Handles StopService.Click
Dim sc As New ServiceController("helpsvc")
If sc.Status = ServiceControllerStatus.Stopped Then
MessageBox.Show("Service is already stopped")
Exit Sub
End If
sc.Stop()
sc.WaitForStatus(ServiceControllerStatus.Stopped)
LabelStatus.Text = sc.Status.ToString
redpic.Visible = True
greenpic.Visible = False
End Sub
I also added a progress bar, but after doing a lot of reading, I just can’t find the correct way of making it grow to 100% full when the service starts and empty again, and the same when the service stops.
Help?