Click here to Skip to main content
15,888,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir

i want code in that my personal computer system information and liecence key of my Operating system display on browser or in string format using .net

so please help me


i get every other information but still i didnt get my moto witch i want.

i hav leagal copy of XP Os so,i want product key of my pc using .net

please help me !


C#
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();
        
    }
}
Posted
Updated 30-Jan-12 23:03pm
v4
Comments
Dalek Dave 31-Jan-12 5:03am    
Edited for Code Block.

 
Share this answer
 
Comments
maddysagar 31-Jan-12 3:29am    
sir i dont want to create a OS license key.
actualy i having legal OS of XP with license so i just want to read my own personal computer OS license key using .net
so please help me m waiting for rpy

thank u sir
maddysagar 31-Jan-12 23:16pm    
thank u sir my prob solved succesfully !!!
Have a look at the Win32_OperatingSystem class[^].
It should give you all the details you need.
 
Share this answer
 
Comments
maddysagar 31-Jan-12 23:16pm    
thank u sir my prob solved succesfully !!!
Abhinav S 1-Feb-12 0:40am    
You are welcome. Vote if it helped.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900