Page 1 of 2 12 LastLast
Results 1 to 40 of 45

Thread: [VB.NET 2005] A Simple Class for Getting Hardware Info

  1. #1

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    [VB.NET 2005] A Simple Class for Getting Hardware Info

    Another question I see somewhat often is how to retrieve processor serial numbers, etc from specific hardware. Most likely used in hardware-lock type licensing. Below are some simple functions for getting hardware specific info such as CPU ID, Motherboard Serial Number, Drive Serial Numbers and MAC address.

    Enjoy! Rate if you like it!


    Code:
    Imports System
    Imports System.Management
    
    Public Class clsComputerInfo
    
        Friend Function GetProcessorId() As String
            Dim strProcessorId As String = String.Empty
            Dim query As New SelectQuery("Win32_processor")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
    
            For Each info In search.Get()
                strProcessorId = info("processorId").ToString()
            Next
            Return strProcessorId
    
        End Function
    
        Friend Function GetMACAddress() As String
    
            Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
            Dim moc As ManagementObjectCollection = mc.GetInstances()
            Dim MACAddress As String = String.Empty
            For Each mo As ManagementObject In moc
    
                If (MACAddress.Equals(String.Empty)) Then
                    If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
    
                    mo.Dispose()
                End If
                MACAddress = MACAddress.Replace(":", String.Empty)
    
            Next
            Return MACAddress
        End Function
    
        Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String
    
            Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter))
            disk.Get()
            Return disk("VolumeSerialNumber").ToString()
        End Function
    
        Friend Function GetMotherBoardID() As String
    
            Dim strMotherBoardID As String = String.Empty
            Dim query As New SelectQuery("Win32_BaseBoard")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
            For Each info In search.Get()
    
                strMotherBoardID = info("SerialNumber").ToString()
    
            Next
            Return strMotherBoardID
    
        End Function
       
    End Class

  2. #2
    New Member
    Join Date
    Dec 2007
    Location
    Land Of The Peace
    Posts
    6

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Thanks dude

    that is clear

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    50

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    thanks man good stuff

  4. #4
    New Member
    Join Date
    Dec 2007
    Location
    Land Of The Peace
    Posts
    6

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Is there any way to confirm the Mother Board ID??

  5. #5
    Member
    Join Date
    Feb 2008
    Posts
    50

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by Abdullah_Dossari
    Is there any way to confirm the Mother Board ID??
    confirm as what?

  6. #6

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    The motherboard ID is just the hardware serial number encoded to the Motherboard. Now, if you're asking "Is there a way to confirm that this is a Dell board vs an Asus board vs a Gigabyte board?", then no, not really.

    There are manufacturer IDs typically encoded into the BIOS, but not all boards support them; and even the ones that do, they can be altered w/o too much trouble by someone who knows what they're doing.

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    I just want to confirm it, does all CPU have serial numbers and are they always unique?
    Regards,

    â„¢

    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    Addicted Member
    Join Date
    Oct 2008
    Posts
    202

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by dee-u
    I just want to confirm it, does all CPU have serial numbers and are they always unique?

    Would also like to know this because then it would be possible to build another nice Software Protection.

    A CPU Serial Number Check

  9. #9

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Yes. CPU ID numbers are always unique, like the VIN numbers on Cars. In fact, ALL four of those examples should always be unique.

    MAC Addresses of network adapters are carefully controlled to be unique to all the network card manufacturers even, and all the hard drive companies have their own serialization method to tag their hard drives.

    The Motherboard ID is a hit or miss though, as some BIOSes may not contain this information.

    All of these are poor substitutes for a dongle though which is the ultimate hardware ID device.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  10. #10
    New Member
    Join Date
    Jan 2009
    Posts
    1

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Hi...

    Ur coding working properly except motherboard. Actualy i have Windows Vista & XP Os on my pc & GetMotherBoardID Function return value is "Not Applicable". How do i get MotherBoard Serial No in Vb.net.

    Thanking in Advance.

    KK

  11. #11

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    If you're not getting a motherboard ID then most likely, the BIOS isn't set up to provide that information for that model of motherboard. It's not available.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  12. #12
    Junior Member
    Join Date
    Nov 2008
    Posts
    18

    Angry Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    I am using VB.NET 2008 and have of course imported everything properly.

    There are many not defined as SelectQuery, ManagementObjectSearcher, ManagementObject, ManagementClass, etc...


    It almost as as if there is something else that needs to be imported.

    This code means a lot to me, What am I missing here?

    I am actually not a newbie to vb.net and that is why I am so fustrated with this.

    By the way I did post this into a class and made sure to name the class the same and all of that.

    Thanks a bunch looking forward to the solution.

  13. #13
    Addicted Member
    Join Date
    Oct 2008
    Posts
    202

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    My Project > References > Add > System.Managment

  14. #14

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Yea, if you don't add a reference to System.Management, it won't work. I kinda figured that was apparent from the "Imports System.Management" at the top of the class.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  15. #15
    Lively Member
    Join Date
    Aug 2009
    Location
    Japan
    Posts
    87

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Could someone tell me what to do with this class once it's installed, how do you actually use it? I have the imports correct but I can't figure out what to do next. Tried to call directly but doesn't show up in the drop down so I know I'm on the wrong track. I'm using VB.net 2008 with vista64 but, don't think it's a compatibility thing, more like a noob thing. Thanks.

  16. #16

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Just like anything else:

    Code:
    Dim hw As New clsComputerInfo
    
    Dim cpu As String
    
    cpu = hw.GetProcessorId()
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  17. #17
    New Member
    Join Date
    Sep 2010
    Posts
    11

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Hi..
    I've tried this code, there is no error, but when i used the 'GetMotherBoardID()' function on a textbox, it filled with 'To be filled by O.E.M.'. is anybody can explain on this case?

  18. #18
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by ardhagp View Post
    Hi..
    I've tried this code, there is no error, but when i used the 'GetMotherBoardID()' function on a textbox, it filled with 'To be filled by O.E.M.'. is anybody can explain on this case?
    I guess that it is exactly what it says; The O.E.M. manufacturer should have put the Motherboard ID there, which they haven't...
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  19. #19
    New Member
    Join Date
    Sep 2010
    Posts
    11

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    i think its little bit hard if we just depend on motherboard's id. if i using cpu id, is there any possibilities for the CPU doesn't have ID just like the motherboad?

  20. #20
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    I'm pretty sure all CPU's has their own unique serial number. Hard drives too...
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  21. #21

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Network MAC address is an excellent serial number to use as well. They're guaranteed to be unique.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  22. #22
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    a lot of errors not defined things
    like
    SelectQuery
    ManagementObjectSearcher
    ManagementObject

    is there is something should i import??
    i'm uusing 2008 not 2005

    thanks at all

  23. #23
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    sorry forget to add the system.management great class
    thank you

  24. #24
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by Jenner View Post
    Another question I see somewhat often is how to retrieve processor serial numbers, etc from specific hardware. Most likely used in hardware-lock type licensing. Below are some simple functions for getting hardware specific info such as CPU ID, Motherboard Serial Number, Drive Serial Numbers and MAC address.

    Enjoy! Rate if you like it!


    Code:
    Imports System
    Imports System.Management
    
    Public Class clsComputerInfo
    
        Friend Function GetProcessorId() As String
            Dim strProcessorId As String = String.Empty
            Dim query As New SelectQuery("Win32_processor")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
    
            For Each info In search.Get()
                strProcessorId = info("processorId").ToString()
            Next
            Return strProcessorId
    
        End Function
    
        Friend Function GetMACAddress() As String
    
            Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
            Dim moc As ManagementObjectCollection = mc.GetInstances()
            Dim MACAddress As String = String.Empty
            For Each mo As ManagementObject In moc
    
                If (MACAddress.Equals(String.Empty)) Then
                    If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
    
                    mo.Dispose()
                End If
                MACAddress = MACAddress.Replace(":", String.Empty)
    
            Next
            Return MACAddress
        End Function
    
        Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String
    
            Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter))
            disk.Get()
            Return disk("VolumeSerialNumber").ToString()
        End Function
    
        Friend Function GetMotherBoardID() As String
    
            Dim strMotherBoardID As String = String.Empty
            Dim query As New SelectQuery("Win32_BaseBoard")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
            For Each info In search.Get()
    
                strMotherBoardID = info("SerialNumber").ToString()
    
            Next
            Return strMotherBoardID
    
        End Function
       
    End Class

    hi sir, i developed a project using VB.Net 2005 and sql server 2005 standard edition at back end. now its complete and have to deliver to company now. but i am afraid that the company may reproduce a new copy of this software from the original CD, WHICH I WILL GIVE THEM, and may sell to any other company or in open market. I want to implement some mechanism on my project for its security, which enables it to not to work on other computers or some similar type security. Or if you people have any better idea, (hopefully you will have) so please tell me. The way you mentioned will it be suitable for my situation?

  25. #25

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Yes. You first use this class to generate some type of hardware ID. An easy way would be the following:

    ChallengeCode = Hash(Encrypt(ProcessorID & MAC Address, key1))

    I take my processor ID and append it to my primary MAC address. Then I encrypt this using some key, and hash it to get a consistent value such as a 10-digit number.

    Next, I report this number as a "challenge code" to whoever I bought the software from. This "challenge code" is used to make a "license key":

    LicenseKey = Hash(Encrypt(ChallengeCode, key2))

    As the software maker, you write a small key-generator that converts any given "challenge code" into a "license key". If they paid their bills, you give them back the "license key".

    The software then does the same computation behind the scenes and compares the "license keys". If they match, it allows access to the software. If not, it shuts down because it's an invalid key.

    The downside is you need an active "registration" system in place (either via a website, email or a person on the other end of a phone). A passive registration system doesn't lock the software to a hardware ID and has universal codes. Compromised codes are eliminated between frequent version updates.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  26. #26
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Ok, Sir please tell me now that how do i implement this code? i mean where do i type this lengthy? I mean on a separate form, or somewhere else? please sir guide me step wise. pleaseeee

  27. #27
    New Member
    Join Date
    May 2011
    Posts
    4

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    to Jenner

    Hello I would like to have more information for your algorithm. I think if I understood correctly that in the software must be a function (for example checkLicense) that generates a license key and compares it with the license key provided to me

    checkLicense = Hash(Encrypt(ChallengeCode, key2))
    if checkLicense = licensekey then
    softwareActivacted
    else software notActivacted

    thanks
    Angelo

  28. #28

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    My last explanation is all in psudocode. The functions to encrypt and hash you need to make yourself. If you look in my signature, you'll see I also have an encryption class with some functions you can use to do this.

    License systems are just basic cryptography. If you want to learn more about the concepts of license systems, authentication systems, and general encryption and hashing, check out this book. It's absolutely excellent. I outlined the basics of how a hardware-locked function would work. It's up to you now to implement the concept into your program.

    You are correct Ansl72, though checkLicense is a variable. The function looks something like this:

    Code:
    'Hash(String) As String: is a hash function.
    'Encrypt(String,String) As String: is an encryption function.
    'ReadLicenseFromSavedFile() As String: is a function that reads license data from some saved license file.
    'SaveLicenseToFile(String): is a function that saves license data to some saved license file.
    'FormDialog_PromptForLicenseKey is a custom dialog that asks for the license key.
    'EnableSoftwareFullUse(): is a function for enabling your software as a full version.
    'key1 and key2 are the keys used by the encrypt function.  They probably shouldn't be stored as plain text like this, but this is a simple example.
    
    Dim key1 As String = "blahblah"
    Dim key2 As String = "wibblewibble"
    Dim hw As New clsComputerInfo 
    Dim challengeCode As String = Hash(Encrypt(hw.GetProcessorID() & hw.GetMACAddress(), key1))
    Dim licenseKey As String = Hash(Encrypt(challengeCode, key2))
    Dim compareKey as String = ReadLicenseFromSavedFile()
    
    If licenseKey = compareKey Then
        EnableSoftwareFullUse()
    Else
        Dim f As New FormDialog_PromptForLicenseKey
        If f.ShowDialog = DialogResult.OK Then
            SaveLicenseToFile(f.LicenseKeyEntered)
            EnableSoftwareFullUse()
        Else
            Me.Close 'Shut down the software, they are not authorized
        End If
    End If
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  29. #29
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Thanks for the benevolence. I have tried to run this on VB 2008. Despite importing the system management I still have errors such as SelectQuery not defined, ManagementObjectSearcher not defined, ManagementObject not defined. I wish to add this code to a button that users could click to have these Ids displayed, but it appears the function can run under method. Any idea how to get rid of this error n circumvent the issue?

  30. #30

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Have you tried:
    Code:
    Dim query As New System.Management.SelectQuery("Win32_processor")
    ?

    If it's telling you those are not defined, you still have a reference problem somewhere. Did you add the reference to System.Management to your project?
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  31. #31
    Lively Member
    Join Date
    Feb 2009
    Posts
    72

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Hi,
    How can I convert this class to Visual Basic 6.0?

    Thanks,

    LVD

  32. #32
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by levanduyet View Post
    Hi,
    How can I convert this class to Visual Basic 6.0?

    Thanks,

    LVD
    You will have to rewrite it! Try searching for "Get Hardware Info" + "VB6" in google.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  33. #33

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Yup, you'll most likely have to use Windows API calls to access the WMI system. I don't even know if WMI even existed when VB6 was written.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  34. #34
    New Member
    Join Date
    Sep 2011
    Posts
    2

    how to get the real serial number from a cpu

    hello.what i want is to get the serial number of my cpu.
    i have used the code you give at your website,that refers at the function GetProcessorId,
    at 3 different pc's,where all these pc's were using cpu's of the company INTEL.
    so my problem is that i took the same ID from the 3 pc's i used.
    is there any way that will make me able to get a real serial number
    from a cpu,that this serial number is unique?i am using visual studio 2008.
    do you have something to suggest?
    Thank you and i am looking forward for your answer.

  35. #35

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    The CPU ID is not a unique serial number. As far as I know, there is no way to retrieve that from the CPU reliably. In some CPUs it's totally disabled, in others, it's not reported, and in a virtual environment, it's not present.

    Your best bet is to use the MAC ID which MUST be unique in order for networking to work. If you want another level, add this to the CPUID which identifies the CPU make, model and features supported.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  36. #36
    New Member
    Join Date
    Oct 2011
    Posts
    4

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Hey, I am new to VB and would like your help...

    I am making a software and want to restrict it to a particular machine, i.e the software cannot be pirated.
    I have decided to do the following

    => Get User HDD Id or MAC Id
    => Save that id to my site
    => Whenever the program is executed it'll automatically check if that user's HDD id or MAC id is available on my site, if it does the program will load or else it'll exit.

    I'm currently having problem with the "Get Id" code
    I want that as soon as the program runs(loads), the HDD id or MAC id is displayed in a textbox.

    Kindly help me with it
    Thankyou

  37. #37
    New Member
    Join Date
    Mar 2012
    Posts
    2

    Thumbs up Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by Jenner View Post
    Another question I see somewhat often is how to retrieve processor serial numbers, etc from specific hardware. Most likely used in hardware-lock type licensing. Below are some simple functions for getting hardware specific info such as CPU ID, Motherboard Serial Number, Drive Serial Numbers and MAC address.

    Enjoy! Rate if you like it!


    Code:
    Imports System
    Imports System.Management
    
    Public Class clsComputerInfo
    
        Friend Function GetProcessorId() As String
            Dim strProcessorId As String = String.Empty
            Dim query As New SelectQuery("Win32_processor")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
    
            For Each info In search.Get()
                strProcessorId = info("processorId").ToString()
            Next
            Return strProcessorId
    
        End Function
    
        Friend Function GetMACAddress() As String
    
            Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
            Dim moc As ManagementObjectCollection = mc.GetInstances()
            Dim MACAddress As String = String.Empty
            For Each mo As ManagementObject In moc
    
                If (MACAddress.Equals(String.Empty)) Then
                    If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
    
                    mo.Dispose()
                End If
                MACAddress = MACAddress.Replace(":", String.Empty)
    
            Next
            Return MACAddress
        End Function
    
        Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String
    
            Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter))
            disk.Get()
            Return disk("VolumeSerialNumber").ToString()
        End Function
    
        Friend Function GetMotherBoardID() As String
    
            Dim strMotherBoardID As String = String.Empty
            Dim query As New SelectQuery("Win32_BaseBoard")
            Dim search As New ManagementObjectSearcher(query)
            Dim info As ManagementObject
            For Each info In search.Get()
    
                strMotherBoardID = info("SerialNumber").ToString()
    
            Next
            Return strMotherBoardID
    
        End Function
       
    End Class

    Hi Jenner,

    I tried your code on vb.net 2010. It works perfect.I have only one doubt in this that is how can i make the software secure so that the tamping happens nowdays with any product it can't happen?

    Wht's the best suggestion you can give in this regard.I don't want the user to crack the code using reassembled,hash editor etc..

    Thanks & Regards.

  38. #38

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    There's no way to make it "totally" uncrackable, but how difficult it'll be depends on how far you're willing to do and how much you're willing to spend.

    First off, just by understanding the basics of encryption and the protocols for using it, you'll put your program way ahead of the pack. Most license systems fail because of poor implementation or reliance on obfuscation. If you add in a code obfuscation tool, you'll be even better.

    Then, you make an automated online licensing system that checks the license code entered into the program against a known list of sold keys (and # of times activated within T timeframe) and you're at the pro level of "uncrackable".

    If you need to go the extra mile, then you'll need either a continuous online system (like many games these days) that checks each time the user wants to use the program, and/or a hardware solution like a dongle-key; a USB plug with needed licensing / program data on it to get your program to run. You can also look into professional licensing systems such as FLEXnet.
    Last edited by Jenner; Apr 2nd, 2012 at 12:39 PM.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  39. #39
    New Member
    Join Date
    Mar 2012
    Posts
    2

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Quote Originally Posted by Jenner View Post
    There's no way to make it "totally" uncrackable, but how difficult it'll be depends on how far you're willing to do and how much you're willing to spend.

    First off, just by understanding the basics of encryption and the protocols for using it, you'll put your program way ahead of the pack. Most license systems fail because of poor implementation or reliance on obfuscation. If you add in a code obfuscation tool, you'll be even better.

    Then, you make an automated online licensing system that checks the license code entered into the program against a known list of sold keys (and # of times activated within T timeframe) and you're at the pro level of "uncrackable".

    If you need to go the extra mile, then you'll need either a continuous online system (like many games these days) that checks each time the user wants to use the program, and/or a hardware solution like a dongle-key; a USB plug with needed licensing / program data on it to get your program to run. You can also look into professional licensing systems such as FLEXnet.
    Hi,

    Thanks for quick reply..Please can you give me some sites.As I am very much interested in this.

  40. #40

    Thread Starter
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [VB.NET 2005] A Simple Class for Getting Hardware Info

    Just search this site and Google for "License System" and "String Encryption"

    If you want a cookie-cutter solution, try these guys: http://www.ssware.com/cryptolicensin...ensing_net.htm
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width