Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Am making a project and part of it involves configuring it to be a trial version until the user has purchased the licence. The licence key is generated after getting the system hardware and generating a code after doing some conversions. I would be grateful if anyone could help show me how to get unique standard hardware information using c# code. I've seen one in c++ but I know nothing about c++ so i'd prefer pure c# code but if I have to reference some c++ classes then its ok as long as you pls show me around.
Posted

I hope this may help you out...

--------------------------------

C#
using System.Data;
using Microsoft.Win32;


C#
private void Form1_Load(object sender, System.EventArgs e)
        {
            try
            {
                label18.Text = SystemInformation.PrimaryMonitorSize.ToString();
                label2.Text = System.Environment.SystemDirectory;
                label4.Text = System.Environment.MachineName;
                label6.Text = System.Environment.WorkingSet.ToString();
                int q = System.Environment.TickCount;
                int w = (q/1000)/60;
                label8.Text = w.ToString() + "  Minute(s)";
                label10.Text = System.Environment.OSVersion.ToString();
                label12.Text = System.Environment.Version.ToString();
                label14.Text = System.Environment.UserName;
                label16.Text = System.Environment.UserDomainName;
                RegistryKey Rkey = Registry.LocalMachine;
                Rkey = Rkey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
                label20.Text = (string)Rkey.GetValue("ProcessorNameString");
            }
            catch (Exception EX)
            {
                MessageBox.Show("The Following ERROR Occur ..." + EX.Message.ToString());
            }
        }



---------------------------------------------------------------------

Did you get the correct result?
 
Share this answer
 
how to get unique standard hardware information using c# code.

Ok. You need to use WMI (Windows Management Instrumentation)

Have a look at this article:
Collecting Hardware Information using C# and WMI[^]

Also, look at this one:
Getting Hardware Information[^]
It's in VB.NET. But should be enough to get you going. (One can easily convert it to C# using free converters and manually resolving error if any.)
 
Share this answer
 
Comments
Mwanzia_M 10-Apr-11 14:24pm    
thanks alot,just what i needed.
Sandeep Mewara 10-Apr-11 14:33pm    
Good to know.
TweakBird 10-Apr-11 14:26pm    
Good link. My 5.
Sandeep Mewara 11-Apr-11 0:29am    
Thanks Eswar.
Wendelius 10-Apr-11 14:49pm    
Very good answer, my 5

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