You need to get the parameters of the CD-ROM (name, manufacturer, etc.). The code does a fine job with getting these parameters:

HDEVINFO hDevInfo = NULL; SP_DEVINFO_DATA DeviceInfoData; hDevInfo = ::SetupDiGetClassDevs( NULL, 0, 0, DIGCF_PRESENT | DIGCF_ALLCLASSES ); if(hDevInfo != INVALID_HANDLE_VALUE) { DeviceInfoData.cbSize = sizeof( SP_DEVINFO_DATA ); for(int i = 0; ::SetupDiEnumDeviceInfo( hDevInfo, i, &DeviceInfoData ); i++) { // ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ для класса CDROM всС Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹Π΅ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹, ΠΊΡ€ΠΎΠΌΠ΅ Π±ΡƒΠΊΠ²Ρ‹ диска } } 

How to get the drive letter of the device? The letter CD / DVD-ROM can be obtained using GetLogicalDriveStrings , GetDriveType But how to associate a device with a designated letter?

    1 answer 1

    How I solved this issue:

     GetLogicalDriveStrings - ΠΏΠΎΠ»ΡƒΡ‡Π΅Π½ΠΈΠ΅ Π±ΡƒΠΊΠ² всСх дисков GetDriveType - поиск CD/DVD-ROM SetupDiGetClassDevs, SetupDiEnumDeviceInfo - поиск дСвайсов ΠΏΠΎ классу "CDROM" RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"SYSTEM\\MountedDevices" ..... RegQueryValueEx( hKey, L"\\DosDevices\\Π±ΡƒΠΊΠ²Π° CD/DVD-ROM 

    casting devces_id from the registry and obtained from SetupDiEnumDeviceInfo to a uniform format for matching the letter and the device.

    Write if there is a more elegant solution.