Ocrana
asked on
Driveletter and IDE Channel
Hello,
do anybody know a way to get the IDEChannel from a Drive letter?
I want to know as sample, if Drive F: is Primary or Secondary channel.
As sample I want to build a table:
C: | Primary | 0
D: | Primary| 1
E: | Secondary | 0
F: | Secondary | 1
Maybe with Registry or other way.
Thanks,
OCrana
do anybody know a way to get the IDEChannel from a Drive letter?
I want to know as sample, if Drive F: is Primary or Secondary channel.
As sample I want to build a table:
C: | Primary | 0
D: | Primary| 1
E: | Secondary | 0
F: | Secondary | 1
Maybe with Registry or other way.
Thanks,
OCrana
Here is a small extract from WinIoCtl.h
So it looks like you can query the info using the Windows Device Driver Kit through a call to DeviceIoControl().
Cheers,
Chris
//
// IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
// number for the handle. This is used to determine if a disk
// is attached to the primary or secondary IDE controller.
//
typedef struct _DISK_CONTROLLER_NUMBER {
DWORD ControllerNumber;
DWORD DiskNumber;
} DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
So it looks like you can query the info using the Windows Device Driver Kit through a call to DeviceIoControl().
Cheers,
Chris
Having just looked through the MSDN information, it looks like DeviceIOControl() calls with IOCTL_DISK_CONTROLLER_NUMB ER are obsolete, so you might have to use IOCTL_STORAGE_QUERY_PROPER TY to get the information you are after. I will try and dig out the parameters required for a IOCTL_STORAGE_QUERY_PROPER TY query to work.
Cheers,
Chris
Cheers,
Chris
As far as I can tell, if you use IOCTL_STORAGE_QUERY_PROPER TY with the STORAGE_PROPERTY_QUERY set to StorageDeviceProperty,Prop ertyStanda rdQuery then the STORAGE_DEVICE_DESCRIPTOR. RawDeviceP roperties[ ] might contain the information you are after. I don't know and couldn't check as I have no IDE disks on my system.
I wil ltry and get together the code for a DeviceIOControl() call using IOCTL_DISK_CONTROLLER_NUMB ER - you can check on your own system if it returns the information you are after.
Cheers,
Chris
I wil ltry and get together the code for a DeviceIOControl() call using IOCTL_DISK_CONTROLLER_NUMB
Cheers,
Chris
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
N.B. you will need the Windows Driver Kit (usually called the DDK) from here http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=11800
#include "WinIOCtl.h" from your SDK headers and #include "Ntdddisk.h" from the directory you install the DKK.
Cheers,
Chris
#include "WinIOCtl.h" from your SDK headers and #include "Ntdddisk.h" from the directory you install the DKK.
Cheers,
Chris
I posted a valid piece of code for the questioner to try - it should give the controller number and disk number on a system with IDE disks. From these two values the IDE channel can be deduced.
Cheers,
Chris
Cheers,
Chris
unfortunately we didn't get any feedback from OCrana. i wonder whether the author was aware that computers with P-ATA (IDE) disks are a rare exception nowadays.
Chris has posted a valid solution. so he should get the points if you decide to add the question to the PAQ database.
Sara
Chris has posted a valid solution. so he should get the points if you decide to add the question to the PAQ database.
Sara
for example if you have one harddisk it could be sata disk and then no ide channel is involved.
or you create one primary partition and 1 extended partion for that disk (channel). and for the extended partition you configure 3 logical drives. then c is the primary partition, d, e, f are the logical drives and all is associated to primary ide channel.
i don't know an api that could go from drive letter to ide channel. the best i know is functions GetVolumeInformation and GetDriveType which would allow to find out whether a drive letter represents a hard disk, cdrom, network share or other.
more info you could get by using system tool diskpart and the command 'list disk'. you also can get that output programmatically by putting the 'list disk' into a textfile and call
Open in new window
where listdisks.scr contains the list command and the partition info is in listdisks.out later.
from diskpart you can get more information about disks, partitions and volumes. for example the commands
Open in new window
would give more detailed disk information like drive letter IDE/SATA such that it is nearly what you want.
Sara