Drive instance id to device id

How to get a device instance identifier from a drive letter?

My process begins with a message about the arrival of the device. I managed to get the drive letter from the arrival message and open the dvd tray.

I searched for various installation API elements; but I did not find anything that led me from the drive letter to the device instance identifier.

A solution in C # or VB.NET would be perfect, but I want to understand it from any other language while I see API calls.

Thanks in advance...

+3
source share
2 answers

You cannot do this directly.

STORAGE_DEVICE_NUMBER. DeviceIoControl IOCTL_STORAGE_GET_DEVICE_NUMBER , . .
, SetupDiGetClassDevs, GUIDS approriate, , . SetupDiEnumDeviceInfo. SetupDiEnumDeviceInterfaces , , SetupDiGetDeviceInterfaceDetail. DevicePath, , STORAGE_DEVICE_NUMBER, . STORAGE_DEVICE_NUMBER , . ! DevInst.

+5

, ^^

, , :

- ( )

- DeviceNotificationFilter, dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE

- VM_DEVICECHANGE

- u , wParam == DBT_DEVICEARRIVAL, lParam, , DBT_DEVTYPE_VOLUME ( ) DBT_DEVTYPE_DEVICEINTERFACE ( lParam InstanceId ).

, DEVINTERFACE, . , -, , (, ^^^) , msdn , .

, , .

, .

+1

Source: https://habr.com/ru/post/1713627/


All Articles