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 drive letter of Hard drive

Get drive letter of Hard drive

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 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
    Madan Chauhan
    wrote on last edited by
    #1

    Hi all, My application is for windows Vista and XP. There are more than on Hard drive connected to my machine. I need to get Drive Letters of the Hard drive from which my system is booting. By using GetLogicalDriveStrings Function I can get the drive letters of all Hard drives. But how can I differentiate that this particular drive letter is the partition name of my booting Hard drive? The structure of disks are: disk0(Booting with this)- C D G disk1- E F H disk2- I J I need to get the C,D,G only. Thanks Madan

    _ 1 Reply Last reply
    0
    • M Madan Chauhan

      Hi all, My application is for windows Vista and XP. There are more than on Hard drive connected to my machine. I need to get Drive Letters of the Hard drive from which my system is booting. By using GetLogicalDriveStrings Function I can get the drive letters of all Hard drives. But how can I differentiate that this particular drive letter is the partition name of my booting Hard drive? The structure of disks are: disk0(Booting with this)- C D G disk1- E F H disk2- I J I need to get the C,D,G only. Thanks Madan

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Call GetLogicalDrives to get all the available drive letters. Call GetSystemDirectory to get the drive which contains the OS. Open the volume using CreateFile("\\.\C:", ... Here replace C: with the drive letter returned in GetSystemDirectory. Call DeviceIControl of the returned handle with the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS code to get the hard disk number. Now you know the hard disk number of the drive containing the OS. Repeat the CreateFile and DeviceIoControl on all the other drive letters and compare the hard disk number with the one you got earlier.

      «_Superman_» I love work. It gives me something to do between weekends.

      M 1 Reply Last reply
      0
      • _ _Superman_

        Call GetLogicalDrives to get all the available drive letters. Call GetSystemDirectory to get the drive which contains the OS. Open the volume using CreateFile("\\.\C:", ... Here replace C: with the drive letter returned in GetSystemDirectory. Call DeviceIControl of the returned handle with the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS code to get the hard disk number. Now you know the hard disk number of the drive containing the OS. Repeat the CreateFile and DeviceIoControl on all the other drive letters and compare the hard disk number with the one you got earlier.

        «_Superman_» I love work. It gives me something to do between weekends.

        M Offline
        M Offline
        Madan Chauhan
        wrote on last edited by
        #3

        Thanks for your kind support. I will apply it today. Thanks Madan

        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