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. How to get disk/drive size

How to get disk/drive size

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorial
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.
  • M Offline
    M Offline
    MKC002
    wrote on last edited by
    #1

    How to get hard disk size, partition size and partition start position in disk through windows API or using win ioctl code I tried to use SetFilePointerEx on winxp but got compile error(unrecognized function)

    L K 2 Replies Last reply
    0
    • M MKC002

      How to get hard disk size, partition size and partition start position in disk through windows API or using win ioctl code I tried to use SetFilePointerEx on winxp but got compile error(unrecognized function)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think you may need the IOCTL_STORAGE_READ_CAPACITY[^] device IO control request.

      MVP 2010 - are they mad?

      A 1 Reply Last reply
      0
      • M MKC002

        How to get hard disk size, partition size and partition start position in disk through windows API or using win ioctl code I tried to use SetFilePointerEx on winxp but got compile error(unrecognized function)

        K Offline
        K Offline
        Kushagra Tiwari
        wrote on last edited by
        #3

        Try using GetDiskFreeSpace Function which will accept driveletter as in parameter. It return's number of clusters available and all you need . Here see in msdn : http://msdn.microsoft.com/en-us/library/aa364935(VS.85).aspx[^] And you can get the drives available through GetLogicalDrives() API. Kushagra

        M 1 Reply Last reply
        0
        • L Lost User

          I think you may need the IOCTL_STORAGE_READ_CAPACITY[^] device IO control request.

          MVP 2010 - are they mad?

          A Offline
          A Offline
          Adam Roderick J
          wrote on last edited by
          #4

          As suggested above DeviceIOControl is needed. In addition to that if you want to get the partition size and partition start position you have to call IOCTL_DISK_GET_DRIVE_LAYOUT_EX([^]) as device control code then you will get the partition data. It has structure DRIVE_LAYOUT_INFORMATION_EX([^]), which will give the required data.

          Величие не Бога может быть недооценена.

          modified on Thursday, February 4, 2010 1:33 AM

          M 1 Reply Last reply
          0
          • K Kushagra Tiwari

            Try using GetDiskFreeSpace Function which will accept driveletter as in parameter. It return's number of clusters available and all you need . Here see in msdn : http://msdn.microsoft.com/en-us/library/aa364935(VS.85).aspx[^] And you can get the drives available through GetLogicalDrives() API. Kushagra

            M Offline
            M Offline
            MKC002
            wrote on last edited by
            #5

            Thanks GetDiskFreeSpace gives geometry of partition (total cluster,sector per cluster, sector size and free cluster). How to get disk(PHYSICALDRIVE0,1..) size. I think GetDiskFreeSpace will not work for it

            1 Reply Last reply
            0
            • A Adam Roderick J

              As suggested above DeviceIOControl is needed. In addition to that if you want to get the partition size and partition start position you have to call IOCTL_DISK_GET_DRIVE_LAYOUT_EX([^]) as device control code then you will get the partition data. It has structure DRIVE_LAYOUT_INFORMATION_EX([^]), which will give the required data.

              Величие не Бога может быть недооценена.

              modified on Thursday, February 4, 2010 1:33 AM

              M Offline
              M Offline
              MKC002
              wrote on last edited by
              #6

              Thanks IOCTL_DISK_GET_DRIVE_LAYOUT gives geometry of partition (size, starting offset in disk, type etc). How to get disk(PHYSICALDRIVE0,1..) size.

              L 1 Reply Last reply
              0
              • M MKC002

                Thanks IOCTL_DISK_GET_DRIVE_LAYOUT gives geometry of partition (size, starting offset in disk, type etc). How to get disk(PHYSICALDRIVE0,1..) size.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                MKC002 wrote:

                How to get disk(PHYSICALDRIVE0,1..) size.

                Follow the link I provided and check out some of the other commands.

                MVP 2010 - are they mad?

                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