using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Management; using System.Management.Instrumentation; using Microsoft.Win32; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GetCPUData(); } public void GetCPUData() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); String cpuName = string.Empty; ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor"); foreach (ManagementObject o in searcher.Get()) { sb.AppendFormat("{0}<p/>", o.ToString()); foreach (PropertyData prop in o.Properties) { sb.AppendFormat("Name: {0} Value : {1}<br/>", prop.Name, prop.Value); if (prop.Name == "Name") cpuName = (String)prop.Value; } } sb.Insert(0, String.Format("<h3>{0}</h3>", cpuName)); Response.Write(sb.ToString()); OSlabel1.Text = System.Environment.OSVersion.ToString(); OSVersionlabel1.Text = System.Environment.Version.ToString(); RegistryKey Rkey = Registry.LocalMachine; Rkey = Rkey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); CPUInfolabel1.Text = (string)Rkey.GetValue("ProcessorNameString"); oskey.Text = System.Environment.SystemDirectory.ToString(); } }
Win32_OperatingSystem
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)