Ilya Matveychikov
Ilya Matveychikov

Reputation: 4024

Name mapping -- \\.\PhysicalDrive to \\.\SCSI

I'm developing in windows with C/C++ and I want to know is it possible to get an apropriate \\.\SCSI device name by \\.\PhysicalDrive ?..

For example, it's wonderful to know how to get that \\.\PhysicalDrive0 is the same that \\.\SCSI0.

Upvotes: 0

Views: 4308

Answers (1)

Oleg
Oleg

Reputation: 222007

Look at the code which I posted in my answer to the question. The author of the question had changed the text of the question so many time and the last version of text clear nor really what the original problem was.

In the example, which C source code you can download here, I show how to get many kind of information about the local drive using different Windows API. The important thing which you need is that some name conversion like DeviceType and DeviceNumber (received by IOCTL_STORAGE_GET_DEVICE_NUMBER) like the following

DeviceType: 7, DeviceNumber: 5, PartitionNumber: 1

are unique in the operation system and can be used to identify the same devices. The reference to the statement you can find in the documentation of IOCTL_STORAGE_GET_DEVICE_NUMBER control code:

The values in the STORAGE_DEVICE_NUMBER structure are guaranteed to remain unchanged until the device is removed or the system is restarted. It is not guaranteed to be persistent across device restarts or system restarts.

In the way you can compare \\.\SCSI0 devices and \\.\PhysicalDrive0 and find out the correspondence.

Upvotes: 1

Related Questions