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. Get Hard Drive Serial Number in VC++

Get Hard Drive Serial Number in VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
7 Posts 4 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.
  • G Offline
    G Offline
    gokings
    wrote on last edited by
    #1

    Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks

    A W A 3 Replies Last reply
    0
    • G gokings

      Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks

      A Offline
      A Offline
      Arsalan Malik
      wrote on last edited by
      #2

      See DiskId32. A Freeware utility, along with VC++ source code!:cool: ARSALAN MALIK

      G 1 Reply Last reply
      0
      • G gokings

        Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks

        W Offline
        W Offline
        wb
        wrote on last edited by
        #3

        I hope this helps...

        CString CDlgReg::GetDriveID()
        {
        char dbits[100],drive[100];
        int i;
        i=0;
        DWORD d=GetLogicalDriveStrings(100, dbits);
        strncpy(drive,dbits+i,4);
        for (int nDrives = 0; nDrives < 26; nDrives ++)
        {
        if(GetDriveType(drive)==DRIVE_FIXED)
        break;
        i+=4;
        strncpy(drive,dbits+i,4);
        }
        char vol[40];
        DWORD mf;
        DWORD sf,sno;
        GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);

        m\_dDriveID=sno;
        CString s;
        s.Format("%08X",sno);	
        return s;
        

        }

        A G 2 Replies Last reply
        0
        • W wb

          I hope this helps...

          CString CDlgReg::GetDriveID()
          {
          char dbits[100],drive[100];
          int i;
          i=0;
          DWORD d=GetLogicalDriveStrings(100, dbits);
          strncpy(drive,dbits+i,4);
          for (int nDrives = 0; nDrives < 26; nDrives ++)
          {
          if(GetDriveType(drive)==DRIVE_FIXED)
          break;
          i+=4;
          strncpy(drive,dbits+i,4);
          }
          char vol[40];
          DWORD mf;
          DWORD sf,sno;
          GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);

          m\_dDriveID=sno;
          CString s;
          s.Format("%08X",sno);	
          return s;
          

          }

          A Offline
          A Offline
          Arsalan Malik
          wrote on last edited by
          #4

          GetVolumeInformation returns logical serial number of a volume, not the serial number of hard drive!;P ARSALAN MALIK

          1 Reply Last reply
          0
          • G gokings

            Can anyone tell me how to obtain the actual hard drive serial number from a VC++ application? Thanks

            A Offline
            A Offline
            Aamir Butt
            wrote on last edited by
            #5

            Win32_DiskDrive is a WMI class which can give u this serial no. Imagine that you are creating a fabric of human destiny with the object of making men happy in the end, giving them peace and rest at last, but that it was essential and inevitable to torture to death only one tiny creature..and to found that edifice on its unavenged tears, would you consent to be the architect on those conditions? Tell me, and tell me the truth! -Fyodor Dostoevsky, The Brothers Karamazov

            1 Reply Last reply
            0
            • W wb

              I hope this helps...

              CString CDlgReg::GetDriveID()
              {
              char dbits[100],drive[100];
              int i;
              i=0;
              DWORD d=GetLogicalDriveStrings(100, dbits);
              strncpy(drive,dbits+i,4);
              for (int nDrives = 0; nDrives < 26; nDrives ++)
              {
              if(GetDriveType(drive)==DRIVE_FIXED)
              break;
              i+=4;
              strncpy(drive,dbits+i,4);
              }
              char vol[40];
              DWORD mf;
              DWORD sf,sno;
              GetVolumeInformation(drive,vol,sizeof(vol),&sno,&mf,&sf,NULL,NULL);

              m\_dDriveID=sno;
              CString s;
              s.Format("%08X",sno);	
              return s;
              

              }

              G Offline
              G Offline
              gokings
              wrote on last edited by
              #6

              Thank you, but this retrieves a so called "serial number" assigned to a logical drive when the drive is formatted. I am interested in the manufacturer's serial number, the REAL serial number of the drive. Thanks for replying.

              1 Reply Last reply
              0
              • A Arsalan Malik

                See DiskId32. A Freeware utility, along with VC++ source code!:cool: ARSALAN MALIK

                G Offline
                G Offline
                gokings
                wrote on last edited by
                #7

                I will check into it. Thank you very much.

                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