using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Management;
public class Form1 : System.Windows.Forms.Form
{
private Label label1;
private Label label2;
private System.ComponentModel.Container components = null;
#region Initialization and dispose
public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#endregion
#region Windows Form Designer generated code
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources=new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1=new System.Windows.Forms.Label();
this.label2=new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize=true;
this.label1.Font=new System.Drawing.Font("Microsoft Sans Serif",12F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte) (161)));
this.label1.Location=new System.Drawing.Point(78,30);
this.label1.Name="label1";
this.label1.Size=new System.Drawing.Size(57,20);
this.label1.TabIndex=0;
this.label1.Text="label1";
//
// label2
//
this.label2.AutoSize=true;
this.label2.Font=new System.Drawing.Font("Microsoft Sans Serif",12F,((System.Drawing.FontStyle) ((System.Drawing.FontStyle.Bold|System.Drawing.FontStyle.Italic))),System.Drawing.GraphicsUnit.Point,((byte) (161)));
this.label2.Location=new System.Drawing.Point(78,63);
this.label2.Name="label2";
this.label2.Size=new System.Drawing.Size(57,20);
this.label2.TabIndex=1;
this.label2.Text="label2";
//
// Form1
//
this.AutoScaleBaseSize=new System.Drawing.Size(5,13);
this.ClientSize=new System.Drawing.Size(226,122);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon=((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
this.MaximizeBox=false;
this.Name="Form1";
this.ShowIcon=false;
this.Text="System information";
this.Load+=new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void Form1_Load(object sender,EventArgs e)
{
ManagementObjectSearcher query;
ManagementObjectCollection queryCollection;
System.Management.ObjectQuery oq;
oq=new System.Management.ObjectQuery("SELECT * FROM Win32_Processor");
query=new ManagementObjectSearcher(oq); // The program retrieves CPU frequency
queryCollection=query.Get(); // from registry but the CIM_Fan statement
foreach (ManagementObject mo in queryCollection) // does not show anything
{
label1.Text=mo["CurrentClockSpeed"].ToString()+ " MHz";
break;
}
oq=new System.Management.ObjectQuery("SELECT * FROM CIM_Fan");
query=new ManagementObjectSearcher(oq);
queryCollection=query.Get();
foreach (ManagementObject mo in queryCollection)
{
label2.Text=mo["Description"].ToString();
break;
}
}
}