Re: How to get the device instance id of a disk or volume? by Mark
Mark
Thu Jan 31 14:33:26 CST 2008
On Jan 31, 2:16=A0pm, Hemant Kulkarni
<HemantKulka...@discussions.microsoft.com> wrote:
> IOCTL_STORAGE_GET_DEVICE_NUMBER =3D> gives the driver number and partition=
> number. I want instance ID the one which I get from
> SetupDiGetDeviceInstanceId ()function.
>
> My problem is how to get Instance ID from disk number like Disk0 Disk1 etc=
>
You can map from the disk number returned by
IOCTL_STORAGE_GET_DEVICE_NUMBER to any of the names for each physical
disk.
typedef struct _STORAGE_DEVICE_NUMBER {
DEVICE_TYPE DeviceType;
ULONG DeviceNumber; <<<< 0..N applied to symbolic link name for
physical device
ULONG PartitionNumber;
} STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
Open the device through the setup api interface name, query its device
number 'N'. That device is DiskN in Disk Manager and is DosDevice
PhysicalDriveN and \Device\HarddiskN\DR0 etc. The common element is
the DeviceNumber returned from IOCTL_STORAGE_GET_DEVICE_NUMBER and it
allows you to correlate all of the various names for physical disk
devices.
>
>
> "Mark Roddy" wrote:
> > IOCTL_STORAGE_GET_DEVICE_NUMBER
>
> > On Jan 31, 1:01 pm, kulkarnihem...@gmail.com wrote:
> > > I am developing a software where I store the Instance ID of every disk=
> > > in the system. How can I get the Instance ID from a disk number? e.g I=
> > > want Instance ID of DIsk0 DIsk1 etc.?
>
> > > here is what I am doing
>
> > > 1] SetupDiClassGuidsFromNameA("DiskDrive",***);
> > > to get the GUID for disk drives
>
> > > 2]SetupDiEnumDeviceInf(***) to enumrate all the disks.This gives me
> > > Instance ID's of all the disks
>
> > > but how can I get the device instance ID of spesific disk(like
> > > Disk0)?- Hide quoted text -
>
> - Show quoted text -