Ask Experts Questions for FREE Help !
    somaraj's Avatar
    somaraj Posts: 2, Reputation: 1
    New Member

    Dec 1, 2004, 01:39 AM
    How to get harddisk information

    I want to retrieve the hard disk information such as
    1) size
    2) Product id
    3) vendor id
    4) serial number
    5) firmware version
    6) model number

    I am able to retrieve the serial number ,firmware version and model number

    But the first 3 I am not able to retrieve . I want to know whether these information are available for a harddisk , if then how to retrive using c++

    If some one knows please help me

    Thanks in advance
    cremedies's Avatar
    cremedies Posts: 304, Reputation: 0
    Full Member

    Dec 6, 2004, 02:07 AM
    I need to know which version of Windows you are using in order to give you the location to find this information.
    somaraj's Avatar
    somaraj Posts: 2, Reputation: 1
    New Member

    Dec 6, 2004, 03:15 AM
    I want my application to work on windows 2000 , given below is what I am doing .Iam not getting the vendorID .I also want whether it is slave/master.
    I don't know how to retrieve this info .

    int done = FALSE;
    int drive = 0;

    // for (drive = 0; drive < MAX_IDE_DRIVES; drive++)
    // {
    HANDLE hPhysicalDriveIOCTL = 0;

    // Try to get a handle to PhysicalDrive IOCTL, report failure
    // and exit if can't.
    char driveName [256];

    sprintf (driveName, "\\\\.\\PhysicalDrive%d", drive);

    // Windows NT, Windows 2000, Windows XP - admin rights not required
    hPhysicalDriveIOCTL = CreateFile (driveName, 0,
    // if (hPhysicalDriveIOCTL == INVALID_HANDLE_VALUE)
    // printf ("Unable to open physical drive %d, error code: 0x%lX\n",
    // drive, GetLastError ());

    if (hPhysicalDriveIOCTL != INVALID_HANDLE_VALUE)
    DWORD cbBytesReturned = 0;

    char buffer [1000];
    memset ((void *) & query, 0, sizeof (query));
    query.PropertyId = StorageDeviceProperty;
    query.QueryType = PropertyStandardQuery;

    memset (buffer, 0, sizeof (buffer));

    if ( DeviceIoControl (hPhysicalDriveIOCTL, IOCTL_STORAGE_QUERY_PROPERTY,
    & query,
    sizeof (query),
    sizeof (buffer),
    & cbBytesReturned, NULL) )
    char serialNumber [1000];

    strcpy (serialNumber,
    flipAndCodeBytes ( & buffer [descrip -> SerialNumberOffset]));
    if (0 == HardDriveSerialNumber [0] &&
    // serial number must be alphanumeric
    // (but there can be leading spaces on IBM drives)
    (isalnum (serialNumber [0]) || isalnum (serialNumber [19])))
    strcpy (HardDriveSerialNumber, serialNumber);

    if(descrip -> VendorIdOffset)
    strcpy(vid, &buffer [descrip -> VendorIdOffset]);
    if(buffer [descrip -> ProductIdOffset])
    strcpy(pid, &buffer [descrip -> ProductIdOffset]);

    // & buffer [descrip -> ProductRevisionOffset],

    DWORD err = GetLastError ();
    char errcod[4];
    char errstr[100]="DeviceIOControl IOCTL_STORAGE_QUERY_PROPERTY error code =";
    AfxMessageBox (errstr);


    memset (buffer, 0, sizeof (buffer));

    CloseHandle (hPhysicalDriveIOCTL);

Not your question? Ask your question View similar questions


Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.

Check out some similar questions!

Portable hard disk disk not opening [ 7 Answers ]

I inserted my portable hard disk in the usb drive and before opening scanned it for viruses.after about half the scan the scanning got stuck at one that instant all programs became non responsive. I then removed my portable disk immediately.then all programs became responsive. But when I...

Information about Hard disk [ 1 Answers ]

Is the physical information( cylinder, Head, sector) reside in HardDisk or BIOS? From where I get this information? If there any function in MFC (VC++) to get the physical information?

Can't see hard disk [ 1 Answers ]

I have two hard disks,one of 40 GB and the other of 200 GB.On the first one I had a 10 GB primary partition and a 30 GB extended one.on the primary partition was installed windows xp.n the extended partition there were two logical drives,one of 20 Gb and the other of 10 GB.I had installed linux on...

Hard disk [ 1 Answers ]

BIOS detects the hard disk and but in hard disk configuration I did not see the cylindar and Track and Sector are there. Will send me the suggestion to repair my hard disk. Deep

View more questions Search