How to get the Device Number in File System Driver

I have created a sample MFC application to find the device number
using IOCTL_STORAGE_GET_DEVICE_NUMBER
following code block used
hDeviceHandle = CreateFile(strDrivePath,0,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);
if (hDeviceHandle != (HANDLE)-1)
{
STORAGE_DEVICE_NUMBER sdn;
DWORD returned;
if (DeviceIoControl( hDeviceHandle,IOCTL_STORAGE_GET_DEVICE_NUMBER,NULL,0,&sdn,sizeof(sdn),&returned,NULL));
{
printf(“\tDevice type: %d number: %d partition: %d\n”,sdn.DeviceType, sdn.DeviceNumber, sdn.PartitionNumber);
}
}

I Need to find out the Device number in file system driver.Is it Possible find the device number in kernel mode .

(Moved to appropriate category)

Nikhil_V_S wrote:

I Need to find out the Device number in file system driver.Is it Possible find the device number in kernel mode .

Are you talking about finding the number for the device where your file
system resides, or for a different device?

The driver layers are abstracted, for good reasons.  You shouldn’t be
making any assumptions about what drivers lie underneath you.  If it
were a network share or some nested file system, then you wouldn’t even
have a device number.

Why do you think you need this?  What are you really trying to do here?

Note: The email was trying to reply to an invalid Discussion (290933).

This IOCTL should be usable in kernel mode.
Mark Roddy

Note: The email was trying to reply to an invalid Discussion (290933).

@Tim_Roberts said:

Are you talking about finding the number for the device where your file
system resides, or for a different device?
same device number.when i connect multiple usb device i need to find out which one is it .

@Mark_Roddy said:

This IOCTL should be usable in kernel mode.
Mark Roddy

thank you @Mark Roddy

Can you please share any sample code .