Operating Sys Source Code
-
Upload
rudresh-cm -
Category
Documents
-
view
216 -
download
0
description
Transcript of Operating Sys Source Code
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.Management;namespace operating_sys{ class Program {
public static void Main() {
ConnectionOptions connection = new ConnectionOptions(); connection.Username = "kushi"; connection.Password = "kushi888"; connection.Authority = "ntlmdomain:DOMAIN";
ManagementScope ms = new ManagementScope("\\\\KUSHI-PC\\root\\CIMV2", connection); ms.Connect(); System.Management.SelectQuery sq = new System.Management.SelectQuery("SELECT * FROM Win32_OperatingSystem"); System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(ms, sq); foreach (System.Management.ManagementObject m in mos.Get()) { Console.WriteLine("Computer Name : {0}", m["csname"]); Console.WriteLine("Windows Directory : {0}", m["WindowsDirectory"]); Console.WriteLine("Operating System: {0}", m["Caption"]); Console.WriteLine("Version: {0}", m["Version"]); Console.WriteLine("Manufacturer : {0}", m["Manufacturer"]);
Console.WriteLine("Free Physical Memory : {0}", m["FreePhysicalMemory"]); Console.WriteLine("Free Virual Memory : {0}", m["FreeVirtualMemory"]); Console.WriteLine("Total Virtual Memory Size : {0}", m["TotalVirtualMemorySize"]); Console.WriteLine("Total Visible Memory Size : {0}", m["TotalVisibleMemorySize"]); Console.WriteLine("Free Physical Memory : {0}", m["FreePhysicalMemory"]);
//Console.WriteLine("CPU Usage : {0}", // m["TotalCPUUsage"]); }
System.Management.SelectQuery sq1 = new System.Management.SelectQuery("SELECT * FROM Win32_PerfFormattedData_Counters_ProcessorInformation"); System.Management.ManagementObjectSearcher mos1 = new System.Management.ManagementObjectSearcher(ms, sq1); Console.WriteLine("CPU Usage"); foreach (System.Management.ManagementObject m in mos1.Get()) {
Console.WriteLine("PercentProcessorTime: {0}", m["PercentProcessorTime"]); } Console.Read(); } }}