Computer details retrieved using Windows Management Instrumentation (WMI) : WMI « Development Class « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Development Class » WMIScreenshots 
Computer details retrieved using Windows Management Instrumentation (WMI)
Computer details retrieved using Windows Management Instrumentation (WMI)


//WMI.cs
//Extracts computer system information using WMI from Microsoft
//Written 01/17/02 John O'Donnell - csharpconsulting@hotmail.com  

using System;
using System.Management;
namespace WMI
{
      /// <summary>
      /// Summary description for WMI.
      /// </summary> 

      public class WMI
      {
            static void Main(string[] args)
            {
                  //
                  // TODO: Add code to start application here
                  //
                  Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)");
                  Console.WriteLine("Written 01/17/02 By John O'Donnell - csharpconsulting@hotmail.com");
                  Console.WriteLine("=========================================================================")

                  ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem";
                  ManagementObjectCollection queryCollection1 = query1.Get();
                  foreachManagementObject mo in queryCollection1 
                  {
                        Console.WriteLine("Name : " + mo["name"].ToString());
                        Console.WriteLine("Version : " + mo["version"].ToString());
                        Console.WriteLine("Manufacturer : " + mo["Manufacturer"].ToString());
                        Console.WriteLine("Computer Name : " +mo["csname"].ToString());
                        Console.WriteLine("Windows Directory : " + mo["WindowsDirectory"].ToString());
                  }                  

                  query1 = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem";
                  queryCollection1 = query1.Get();
                  foreachManagementObject mo in queryCollection1 
                  {
                        Console.WriteLine("Manufacturer : " + mo["manufacturer"].ToString());
                        Console.WriteLine("Model : " + mo["model"].ToString());
                        Console.WriteLine(mo["systemtype"].ToString());
                        Console.WriteLine("Total Physical Memory : " + mo["totalphysicalmemory"].ToString());
                  }  

                  query1 = new ManagementObjectSearcher("SELECT * FROM Win32_processor";
                  queryCollection1 = query1.Get();
                  foreachManagementObject mo in queryCollection1 
                  {
                        Console.WriteLine(mo["caption"].ToString());
                  }                       

                  query1 = new ManagementObjectSearcher("SELECT * FROM Win32_bios";
                  queryCollection1 = query1.Get();
                  foreachManagementObject mo in queryCollection1 
                  {
                        Console.WriteLine(mo["version"].ToString());
                  }                                   

                  query1 = new ManagementObjectSearcher("SELECT * FROM Win32_timezone";
                  queryCollection1 = query1.Get();
                  foreachManagementObject mo in queryCollection1 
                  {
                        Console.WriteLine(mo["caption"].ToString());
                  }                             
            }
      }
}
           
       
Related examples in the same category
1.Management Object SearcherManagement Object Searcher
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.