Dim service() As System.ServiceProcess.ServiceController = System.ServiceProcess.ServiceController.GetServices()
Dim 服务名称 As String = "需要判断的服务名称"
For Each sv As System.ServiceProcess.ServiceController In service
'Output.Show(sv.ServiceName & ",状态=" & sv.Status) ’显示所有服务和状态
If sv.ServiceName = 服务名称 AndAlso sv.Status = System.ServiceProcess.ServiceControllerStatus.Running Then
msgbox("服务已经启动")
Exit For
End If
Next
[此贴子已经被作者于2022/7/7 11:35:16编辑过]