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