473,473 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Different between two ways to get WMI

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
Nov 21 '05 #1
1 1120
yxq
Why the first way will not work sometimes, but the second way can?

"yxq" <ga***@163.net> дÈëÏûÏ¢ÐÂÎÅ:%2****************@tk2msftngp13.phx.g bl...
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
82
by: zardoz | last post by:
I've got this problem: unsigned long long lTemp; char cLargeNum="1324567890"; sscanf(clargeNum,"%llu",&lTemp); which under Win32 isn't working*. My program needs to compile under posix so...
2
by: Chetan Raj | last post by:
Hi, What are the different ways in which a virtual function can be implemented by the C++ compiler? I know VTABLE and VPOINTER is only one of the way. What are the other ways? What are the pros...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
8
by: Bernard Lebel | last post by:
Hello, I would like to know if there is a way to run a Python file under a different user account than the one logged in. Allow me to explain. There are a bunch of people here, they are "basic...
2
by: John | last post by:
Hi I have a single front end to which I would like to select one of two backbends at start-up. How can I accomplish this via code? Also is it possible to leave the "active" backend to last used...
8
by: nobrow | last post by:
Okay ... Im out of practice. Is it not possible to have a 2D array where each column is of a different type, say an int and a struct*? The following seg faults for me and I cant figure out what I...
26
by: Cliff Williams | last post by:
Can someone explain the pros/cons of these different ways of creating a class? // 1 function myclass() { this.foo1 = function() {...} } // 2a
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
0
by: nancylife | last post by:
When developing web report, many developers use VMware to simulate different operating systems on a same server. Then, they can realize cross-platform deployment and debug of web report. According to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.