@H_502_2@
发现要使用WMI,不一定要引用microsoft wmi scripting@H_502_2@
如下:找出安装的sql Server服务 @H_502_2@
Dim objServer As Object @H_502_2@
Dim objSet As Object @H_502_2@
Dim obj As Object @H_502_2@
Dim strComputer As String,strServiceName As String @H_502_2@
Dim idx As Integer @H_502_2@
ReDim g_strsqlServer(32) @H_502_2@
strComputer = "." @H_502_2@
idx = 0 @H_502_2@
Set objServer = GetObject("Winmgmts://" &strComputer)@H_502_2@
Set objSet = objServer.InstancesOf("Win32_Service") @H_502_2@
For Each obj In objSet @H_502_2@
strServiceName = UCase(obj.Name) @H_502_2@
If InStr(strServiceName,"MSsql") > 0 then @H_502_2@
g_strsqlServer(idx) = obj.Name @H_502_2@
idx = idx + 1 @H_502_2@
End If @H_502_2@
Next@H_502_2@
此代码在window2000,VB6,sqlServer2000下通过@H_502_2@
甚至于:@H_502_2@
GetOjbect可以换成CreateObject@H_502_2@
唯一的区别就是,@H_502_2@
不能定义如WbemScripting.SwbemObject,全要换成object@H_502_2@ 原文链接:https://www.f2er.com/vb/259502.html