標題:
[分享]
windows服務 停止或啟動
[打印本頁]
作者:
Min
時間:
2010-5-9 22:07
標題:
windows服務 停止或啟動
Private Sub AA_Click()
If SwitchService("Messenger", True) Then
MsgBox "OK !"
End If
End Sub
Private Function SwitchService(strSvcName As String, blnOpen As Boolean) As Boolean
Dim strWMIcls As String
Dim objSvc As Object
strWMIcls = "Win32_Service"
Set objSvc = GetObject("winmgmts:").InstancesOf(strWMIcls)(strWMIcls & ".Name=""" & strSvcName & """")
SwitchService = CallByName(objSvc, IIf(blnOpen, "StartService", "StopService"), 1) = 0
End Function
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)