No announcement yet.

Drive Sizes

  • Filter
  • Time
  • Show
Clear All
new posts

  • Drive Sizes

    Anyone have experience in attaining the drive sizes (not the partition sizes!) via api calls?

    I beleive I can use the OCTL_DISK_GET_DRIVE_GEOMETRY in WinNT, but in Win 9x I'm stumped.
    <b>George W. Bleck</b>
    <img src=''>

  • #2
    Check out the GetDiskFreeSpace API. In addition to free space, it gives you the numbers you need to calculate the disk size. Total clusters, sectors per cluster, and bytes per sector.

    -- Eric

    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    "Not my circus, not my monkeys."


    • #3
      If you create two partitions on your hard drive, GetDiskFreeSpace() will return the size of each partition, not the physical drive size.

      The only way to do it is through DeviceIoControl and VWIN32_DIOC_DOS_DRIVEINFO. I don't have a specific example, but that should get you started.


      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Home of the BASIC Gurus


      • #4
        For what's it's worth, and I know it's not the same topic, but can the same information here be used for what you are looking for??? (GetVolumeInformation)

        Function DriveSerialNumber(Drive As String)Export As String
        Local HWord As Word
        Local LWord As Word
        Local Volname As Asciiz * 16
        Local VolBuffer As Asciiz * 255
        Local lpVolumeSerialNumber As Long
        Local lpMaximumComponentLength As Long
        Local lpFileSystemFlags As Long
        Local FileSysBuffer As Asciiz * 255
        If GetVolumeInformation (ByCopy Drive, VolBuffer, SizeOf(VolBuffer), lpVolumeSerialNumber , lpMaximumComponentLength, _
        lpFileSystemFlags , FilesysBuffer, SizeOf(FilesysBuffer)) <> 0 Then
            HWord = HiWrd(lpVolumeSerialNumber)
            LWord = LoWrd(lpVolumeSerialNumber)
            Function = Right$("0000000"+Hex$(HWord), 4) + "-" + Right$("0000000"+Hex$(LWord), 4)
            Function = "Cannot Read Drive.."
        End If
        End Function

        mailto:[email protected][email protected]</A>
        Scott Turchin
        MCSE, MCP+I
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi