Different between two ways to get WMI

Y

yxq

Hello,
I want to get some system info using WMI class, but there are two ways, i
want to know what different between them, thank you.

The first:
******************************************
Dim info As ManagementObject
Dim search As ManagementObjectSearcher
search = New ManagementObjectSearcher("SELECT * From
Win32_OperatingSystem")
For Each info In search.Get()
Messagebox.Show info("Caption")
Next


The Second:
*******************************************
Public objWMI As Object
Public colItems As Object
Public objItem As Object
objWMI = GetObject("WinMgmts:/root/cimv2")
colItems = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem")

For Each objItem In colItems
Messagebox.Show objItem.Caption
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top