微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VB中使用WMI 二(不用引用microsoftwmi scripting的方法)


发现要使用WMI,不一定要引用microsoft wmi scripting

如下:找出安装的sql Server服务

Dim objServer As Object

Dim objSet As Object

Dim obj As Object

Dim strComputer As String,strServiceName As String

Dim idx As Integer

ReDim g_strsqlServer(32)

strComputer = "."

idx = 0

Set objServer = Getobject("Winmgmts://" &strComputer)

Set objSet = objServer.InstancesOf("Win32_Service")

For Each obj In objSet

strServiceName = UCase(obj.Name)

If InStr(strServiceName,"MSsql") > 0 then

g_strsqlServer(idx) = obj.Name

idx = idx + 1

End If

Next

代码在window2000,VB6,sqlServer2000下通过

甚至于:

Getojbect可以换成CreateObject

上一次所 讲的几种方法都可以使用。

唯一的区别就是,

不能定义如WbemScripting.SwbemObject,全要换成object

原文地址:https://www.jb51.cc/vb/259502.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐