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. Windows API
  4. using WIN API CreateFile to get a handle for all storage devices

using WIN API CreateFile to get a handle for all storage devices

Scheduled Pinned Locked Moved Windows API
sysadminjsonquestion
5 Posts 2 Posters 7 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
    Mickey Marshall
    wrote on last edited by
    #1

    I'm trying to read all partition info on all drives: NoRootDirectory = 1, Removable = 2, Fixed = 3, Network = 4, CDRom = 5, Ram = 6, currently I can open and read the hard drive partitions using: DeviceName = String.Format("\\\\?\\GLOBALROOT\\Device\\Harddisk(0)\\Partition{1)", 0, 1); Handle = CreateFile(DeviceName, 0, FileShare.Read, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);// FileAttributes.Normal, IntPtr.Zero); where c:=0 and 1=is the first partition on c: Then I use DeviceIoControl to read the partition and volume information what would the names be for the other drive types? Thanks

    MRM

    K 2 Replies Last reply
    0
    • M Mickey Marshall

      I'm trying to read all partition info on all drives: NoRootDirectory = 1, Removable = 2, Fixed = 3, Network = 4, CDRom = 5, Ram = 6, currently I can open and read the hard drive partitions using: DeviceName = String.Format("\\\\?\\GLOBALROOT\\Device\\Harddisk(0)\\Partition{1)", 0, 1); Handle = CreateFile(DeviceName, 0, FileShare.Read, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);// FileAttributes.Normal, IntPtr.Zero); where c:=0 and 1=is the first partition on c: Then I use DeviceIoControl to read the partition and volume information what would the names be for the other drive types? Thanks

      MRM

      K Offline
      K Offline
      kd boss1997
      wrote on last edited by
      #2

      Here

      M 1 Reply Last reply
      0
      • M Mickey Marshall

        I'm trying to read all partition info on all drives: NoRootDirectory = 1, Removable = 2, Fixed = 3, Network = 4, CDRom = 5, Ram = 6, currently I can open and read the hard drive partitions using: DeviceName = String.Format("\\\\?\\GLOBALROOT\\Device\\Harddisk(0)\\Partition{1)", 0, 1); Handle = CreateFile(DeviceName, 0, FileShare.Read, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);// FileAttributes.Normal, IntPtr.Zero); where c:=0 and 1=is the first partition on c: Then I use DeviceIoControl to read the partition and volume information what would the names be for the other drive types? Thanks

        MRM

        K Offline
        K Offline
        kd boss1997
        wrote on last edited by
        #3

        But you probably should just use boost::filesystem. Its what the filesystem TS is based off of. :cool:

        M 1 Reply Last reply
        0
        • K kd boss1997

          But you probably should just use boost::filesystem. Its what the filesystem TS is based off of. :cool:

          M Offline
          M Offline
          Mickey Marshall
          wrote on last edited by
          #4

          I am using managed code (c#). Can you tell me what "boost::filesystem" would be in c#? Thanks

          MRM

          1 Reply Last reply
          0
          • K kd boss1997

            Here

            M Offline
            M Offline
            Mickey Marshall
            wrote on last edited by
            #5

            I read this and it was extremely helpful. I can use things like: \\?\PhysicalDrive0 \\?\CDRom0 to get the number of partitions on the devices I can use: \\?\GLOBALROOT\Device\Harddisk0\Partition0 \\?\GLOBALROOT\Device\CDRom0\Partition0 to get handles to the various partitions on fixed and removable drives but not on cdroms Any suggestions on how to get partition info for cd drives? Thanks

            MRM

            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