Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to read a property array stored in a WMI class?

Posted on 2004-08-05
4
Medium Priority
?
1,101 Views
Last Modified: 2012-08-13
I'm trying to read the property ChassisTypes from the  WMI class, Win32_SystemEnclosure, but am experiencing problems.  

The property itself contains a property array of type uint16, and I'm not certain how to read this in, so that i can display it.  I'm able to access non array types without any problems, but am not certain on how to go about getting the values from this array.

Could someone give me an example of how to do this in VB.NET ?  I'm completely stuck!
0
Comment
Question by:pringlet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 2000 total points
ID: 11725540
This works for me

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objWMIService As Object
        Dim colchassis As Object
        Dim objchassis As Object
        Dim objItem As Object

        objWMIService = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\\Ronald\root\cimv2")
        colChassis = objWMIService.ExecQuery _
            ("Select * from Win32_SystemEnclosure")
        For Each objChassis In colChassis
            For Each objItem In objChassis.ChassisTypes
                MsgBox("Chassis Type: " & objItem)
            Next
        Next
    End Sub

Chassistype

1 Other
2 Unknown
3 Desktop
4 Low Profile Desktop
5 Pizza Box  
6 Mini Tower
7 Tower
8 Portable
9 Laptop
10 Notebook
11 Hand Held
12 Docking Station
13 All in One
14 Sub Notebook
15 Space-Saving
16 Lunch Box  
17 Main System Chassis
18 Expansion Chassis
19 SubChassis
20 Bus Expansion Chassis
21 Peripheral Chassis
22 Storage Chassis
23 Rack Mount Chassis
24 Sealed-Case PC
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11726077
Try:

Dim intType As Integer = Convert.ToInt32(objItem)

Bob

0
 

Author Comment

by:pringlet
ID: 11726629
Cheers

Apologies, meant to say i am using the ManagementObject type objects for this code :-

e.g

Private objOS As ManagementObjectSearcher
Private objMgmt As ManagementObject
Private m_strComputerName As String
       
               
Public Sub New()
objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")

For Each objMgmt In objOS.Get
  m_strComputerName = objMgmt("csname").ToString()
  msgbox (m_strComputerName)
Next

Is anyone familiar with how to do it via this type of methodology for the array type mentioned above?  
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11726702
Not exactly, but if you are trying to get Computer Name, then this is also possible:

SystemInformation.ComputerName

Bob
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question