Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Hard disk serial

Hard disk serial

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fabio Miguez
    wrote on last edited by
    #1

    Hey all, Trying to retrieve the hd serial through VC++ 6.0, not finding a way to do it. MSDN only had WMI scripting for this, and that's over my head. Is that the only way? Best Regards Fabio Miguez

    D T 2 Replies Last reply
    0
    • F Fabio Miguez

      Hey all, Trying to retrieve the hd serial through VC++ 6.0, not finding a way to do it. MSDN only had WMI scripting for this, and that's over my head. Is that the only way? Best Regards Fabio Miguez

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Does this help?


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      F 1 Reply Last reply
      0
      • D David Crow

        Does this help?


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        F Offline
        F Offline
        Fabio Miguez
        wrote on last edited by
        #3

        Hey David, Thanks a lot for the link. I am running through the code right now, and a lot of it is foreign to me, but I will see how I can implement this onto my code. I am also having problems compiling, but the .exe available at the site works. I would like to take advantage of the moment to ask if it has to be this complex, getting a serial number for the HD. Is there no function or simpler code able to do it? Thanks again! Best Regards Fabio Miguez

        B 1 Reply Last reply
        0
        • F Fabio Miguez

          Hey David, Thanks a lot for the link. I am running through the code right now, and a lot of it is foreign to me, but I will see how I can implement this onto my code. I am also having problems compiling, but the .exe available at the site works. I would like to take advantage of the moment to ask if it has to be this complex, getting a serial number for the HD. Is there no function or simpler code able to do it? Thanks again! Best Regards Fabio Miguez

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          GetVolumeInformation - See the lpVolumeSerialNumber field in the data structure. Maybe that is the information you wanted.

          F 1 Reply Last reply
          0
          • B Blake Miller

            GetVolumeInformation - See the lpVolumeSerialNumber field in the data structure. Maybe that is the information you wanted.

            F Offline
            F Offline
            Fabio Miguez
            wrote on last edited by
            #5

            Hey Blake, Great, it seems I am getting somewhere now. I have implemented it in my test dialog, and lpVolumeNameBuffer and lpFileSystemNameBuffer are correct (the drive name and NTFS were returned properly). The serial number looks good, a 7 digit integer, but when I compare to the serial given by diskid32.exe, the program suggested above, they do not match. The serial on diskid32.exe has a mix of alphanumeric characters. The one I am obtaining using GetVolumeInformation can only be an integer, since the parameter used to store it is a DWORD, and I am formatting it as such: m_sResults.Format("%d", &SerialNumber); Any ideas where I could check the actual disk serial, short of looking on the HD casing? I use a laptop, so that would be a little harder than on a desktop. Thanks again, great help! Best Regards Fabio Miguez

            D 1 Reply Last reply
            0
            • F Fabio Miguez

              Hey Blake, Great, it seems I am getting somewhere now. I have implemented it in my test dialog, and lpVolumeNameBuffer and lpFileSystemNameBuffer are correct (the drive name and NTFS were returned properly). The serial number looks good, a 7 digit integer, but when I compare to the serial given by diskid32.exe, the program suggested above, they do not match. The serial on diskid32.exe has a mix of alphanumeric characters. The one I am obtaining using GetVolumeInformation can only be an integer, since the parameter used to store it is a DWORD, and I am formatting it as such: m_sResults.Format("%d", &SerialNumber); Any ideas where I could check the actual disk serial, short of looking on the HD casing? I use a laptop, so that would be a little harder than on a desktop. Thanks again, great help! Best Regards Fabio Miguez

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Fabio Miguez wrote: m_sResults.Format("%d", &SerialNumber); Do you mean to take the address of, rather than the value of, SerialNumber?


              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              F 1 Reply Last reply
              0
              • D David Crow

                Fabio Miguez wrote: m_sResults.Format("%d", &SerialNumber); Do you mean to take the address of, rather than the value of, SerialNumber?


                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                F Offline
                F Offline
                Fabio Miguez
                wrote on last edited by
                #7

                Hey Dave, Damn it, you are right, I screwed that one up. But, on removing the & to get the value, not the address, I get a negative number. Perhaps this is happening due to the integer Format I perform? How could I place this value onto m_sResult (a CString) with alphanumeric characters? Thanks again. Best Regards Fabio Miguez

                R 1 Reply Last reply
                0
                • F Fabio Miguez

                  Hey all, Trying to retrieve the hd serial through VC++ 6.0, not finding a way to do it. MSDN only had WMI scripting for this, and that's over my head. Is that the only way? Best Regards Fabio Miguez

                  T Offline
                  T Offline
                  thompsons
                  wrote on last edited by
                  #8

                  Fabio, I also needed the information you seek. I downloaded the DiskId32 and also had compile problems; (4) errors. Were you able to get around the compile errors? The *.exe runs fine, but won't recompile under VC++ 6.0... Would appreciate any suggestions you may have. Thanks, Steve.

                  F 1 Reply Last reply
                  0
                  • F Fabio Miguez

                    Hey Dave, Damn it, you are right, I screwed that one up. But, on removing the & to get the value, not the address, I get a negative number. Perhaps this is happening due to the integer Format I perform? How could I place this value onto m_sResult (a CString) with alphanumeric characters? Thanks again. Best Regards Fabio Miguez

                    R Offline
                    R Offline
                    Ryan Binns
                    wrote on last edited by
                    #9

                    Fabio Miguez wrote: But, on removing the & to get the value, not the address, I get a negative number. HDD serial numbers/volume IDs are unsigned, and are usually given as hex, so use %x rather than %d (or %u if you want a decimal number).

                    Ryan

                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                    1 Reply Last reply
                    0
                    • T thompsons

                      Fabio, I also needed the information you seek. I downloaded the DiskId32 and also had compile problems; (4) errors. Were you able to get around the compile errors? The *.exe runs fine, but won't recompile under VC++ 6.0... Would appreciate any suggestions you may have. Thanks, Steve.

                      F Offline
                      F Offline
                      Fabio Miguez
                      wrote on last edited by
                      #10

                      Hey Steve and Ryan, It seems GetVolumeInformation doesn't return the HDD serial, but the "volume" serial, which changes every time you format the HDD (or is the same for cloned HDDs, which a bunch of manufacturers do). Apparently there is no easy way to get HDD serials, short of the complex (to me) code in diskid32. I also found that my number is negative because under Windows, when formatting a drive, the volume serial can be either positive or negative. So you could use this number for copy protection, but if the user passes it on to someone who happens to have the same model of computer (say, the same Dell), this volume serial might be the same. What are the chances? Not great, but this is definitely not the way to go for large scale applications. Microsoft activation, for example, uses the actual HDD serial, among others, probably with code similar to diskid32. My question now is are there any other hardware serials (video card, mobo, memory) that are more easily accessible to begginers like me? Best Regards Fabio Miguez

                      B 1 Reply Last reply
                      0
                      • F Fabio Miguez

                        Hey Steve and Ryan, It seems GetVolumeInformation doesn't return the HDD serial, but the "volume" serial, which changes every time you format the HDD (or is the same for cloned HDDs, which a bunch of manufacturers do). Apparently there is no easy way to get HDD serials, short of the complex (to me) code in diskid32. I also found that my number is negative because under Windows, when formatting a drive, the volume serial can be either positive or negative. So you could use this number for copy protection, but if the user passes it on to someone who happens to have the same model of computer (say, the same Dell), this volume serial might be the same. What are the chances? Not great, but this is definitely not the way to go for large scale applications. Microsoft activation, for example, uses the actual HDD serial, among others, probably with code similar to diskid32. My question now is are there any other hardware serials (video card, mobo, memory) that are more easily accessible to begginers like me? Best Regards Fabio Miguez

                        B Offline
                        B Offline
                        Blake Miller
                        wrote on last edited by
                        #11

                        Fabio, Are you trying to lock to a specific computer? In that case, use multiple hardware keys and multiple system metrics and allow the program to work if a 'majority' of them are met. Use hard drive volume numbers, get the MAC address of the network card if there is a network card, use a hash of monitor type name, you could look up modem manufacturer or modem type, memory quantity, sound card manufacturer or type, etc. You save all these bits of information somewhere, and when you do your check, you allow it to be successful if several of the items are still valid (for example, user might have temporarily used a different monitor, but it is unlikely they constantly add or remove memory or change hard drives around). This way, you are not dependnet upon one single bit of information that might change, and as a result, constantly issuing new keys to your users unecessarily.

                        F 1 Reply Last reply
                        0
                        • B Blake Miller

                          Fabio, Are you trying to lock to a specific computer? In that case, use multiple hardware keys and multiple system metrics and allow the program to work if a 'majority' of them are met. Use hard drive volume numbers, get the MAC address of the network card if there is a network card, use a hash of monitor type name, you could look up modem manufacturer or modem type, memory quantity, sound card manufacturer or type, etc. You save all these bits of information somewhere, and when you do your check, you allow it to be successful if several of the items are still valid (for example, user might have temporarily used a different monitor, but it is unlikely they constantly add or remove memory or change hard drives around). This way, you are not dependnet upon one single bit of information that might change, and as a result, constantly issuing new keys to your users unecessarily.

                          F Offline
                          F Offline
                          Fabio Miguez
                          wrote on last edited by
                          #12

                          Hey Blake, Yeah, trying to lock it to a certain machine. The idea behind the HDD serial was that would stop the user from copying the program to another HDD, and also allow him to change whatever hardware he needed on the machine (video card, monitor, etc.) without having to request a new key. If he changed HDDs, then he would need a new key. But I have been frustrated by how seemingly complex it has been to retrieve the HDD serial, so I am open to other ideas. Your suggestion is very good, but I don't know how to retrieve any of the information you mentioned. I have not yet searched for it (at work, not much time right now), but do you know of any offhand? Thanks a ton. Best Regards Fabio Miguez

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups