Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 131,652 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 3,543 people online right now. Registration is fast and FREE... Join Now!




special hardware ID

 
Reply to this topicStart new topic

special hardware ID, A question..

virusinfektion
post 3 Oct, 2008 - 03:20 PM
Post #1


New D.I.C Head

*
Joined: 11 Aug, 2008
Posts: 13

Ok. In my application I want to generate a special hardware ID from your haddisk. This special ID will be added in application so that only the selected users can run the application. How can I go abouts of doing this?
User is offlineProfile CardPM

Go to the top of the page


gbertoli3
post 3 Oct, 2008 - 04:04 PM
Post #2


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


You can use the System.Management Namespace.

To do this you need to add a reference to System.Management

Hope this helps
User is offlineProfile CardPM

Go to the top of the page

virusinfektion
post 3 Oct, 2008 - 04:28 PM
Post #3


New D.I.C Head

*
Joined: 11 Aug, 2008
Posts: 13

Yes that did help. Now I can generate a hardware id.. Now how can i set that to a user login? or is this possible?

For example: I'd give the hardware id generator to the user, they'd send me their hardware id and ill add it to the program to that only the users can use it and only them. No others.
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 3 Oct, 2008 - 04:46 PM
Post #4


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


If I understand you right you want to basically double verify that it really is the user. You want it so that even if a hacker has their username & password it won't work because they will need the exact same computer with the exact same hardware.

Is that right?
User is offlineProfile CardPM

Go to the top of the page

virusinfektion
post 3 Oct, 2008 - 07:11 PM
Post #5


New D.I.C Head

*
Joined: 11 Aug, 2008
Posts: 13

Exactly, is that possible?
User is offlineProfile CardPM

Go to the top of the page

Jayman
post 3 Oct, 2008 - 07:14 PM
Post #6


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,819



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Topic renamed to be more descriptive of the problem.
User is offlineProfile CardPM

Go to the top of the page

virusinfektion
post 3 Oct, 2008 - 08:04 PM
Post #7


New D.I.C Head

*
Joined: 11 Aug, 2008
Posts: 13

QUOTE(jayman9 @ 3 Oct, 2008 - 08:14 PM) *

Topic renamed to be more descriptive of the problem.

Cheers jayman
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 3 Oct, 2008 - 08:30 PM
Post #8


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


Yes it is, but most people won't take their time to do that.

Here is a sample of what you could do:
csharp

String Username = usernameTextBox.Text;
String Password = passwordTextBox.Text;
Boolean allowLogin = false;

private void CheckIDs()
{
System.Management.SelectQuery Query = new System.Management.SelectQuery("Win32_Processor");
System.Management.ManagementObjectSearcher Searcher = new System.Management.ManagementObjectSearcher(Query);
System.Management.ManagementObject ManageObject = new System.Management.ManagementObject();

//Check if the username is equal to the saved username
if (Username.ToLower() == Properties.Settings.Default.Username.ToLower())
{
//Check if the password is equal to the saved password
if (Password.ToLower() == Properties.Settings.Default.Password.ToLower())
{
//Check if the user's ProcessorID is equal to the saved ProcessID
if (ManageObject["ProcessorId"].ToString() == Properties.Settings.Default.ProcessID)
{
//A Boolean that will allow you to login
allowLogin = true;
Login();
}
else
{
//A Boolean that will not allow you to login
allowLogin = false;
}
}
}
}

private void Login()
{
if (allowLogin == true)
{
//Add your Login Code
}
else
{
//Do Nothing
//Or
//Add your Other Code
}
}


Hope this gets you started

This post has been edited by gbertoli3: 3 Oct, 2008 - 08:32 PM
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 4 Oct, 2008 - 07:53 AM
Post #9


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


There is a flaw in your idea.

If the user replaces his/her processor for a new one then they are screwed! They can't get in because the ProcessorID will be different for each processor.

This post has been edited by gbertoli3: 4 Oct, 2008 - 07:53 AM
User is offlineProfile CardPM

Go to the top of the page

virusinfektion
post 4 Oct, 2008 - 09:04 AM
Post #10


New D.I.C Head

*
Joined: 11 Aug, 2008
Posts: 13

I would have to add their new hardware id to the program.

Thanks for the help gbertoli3 the code helped alot, I believe I got it now wink2.gif

This post has been edited by virusinfektion: 4 Oct, 2008 - 09:05 AM
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 4 Oct, 2008 - 09:23 AM
Post #11


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


Sure No Problem!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 06:29AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month