Click here to Skip to main content
14,093,423 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190518.1 | Last Updated 29 May 2009
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100