title: Associate CDRom device with drive letter
body: <p>I am writing a program that makes disk images of a CD-ROM drive. I need to create a full disk image, not just a volume image, but I need a volume name so I can name the resulting file accordingly.</p>
  
  <p>Basically I need this:</p>
  
  <p><a href="https://i.stack.imgur.com/nd3cK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nd3cK.png" alt="image"></a></p>
  
  <p>I know that my CD-ROM drive is CD-ROM 0, and I need to know which volumes are there.</p>
  
  <p>I tried to query WMI from PowerShell, but no luck. </p>
  
  <p><code>Get-WMIObject -Class Win32_LogicalDisk</code> gives me all drive letters and volume labels. </p>
  
  <p><code>Get-WmiObject Win32_DiskPartition</code> gives me a list of partitions without any labels/letters. </p>
  
  <p><code>Get-WMIObject -Class Win32_PhysicalMedia</code> is gives me a device address (?) like <code>\\.\CDROM0</code>. </p>
  
  <p><code>Get-WMIObject -Class Win32_DiskDrivePhysicalMedia</code> is useless, it just has hard drives in it, no CD-ROMs. </p>
  
  <p>What am I missing?</p>
  
  <p>I want a way to see that <code>\\.\CDROM0</code> has a volume with letter D and whatever label. Is there a way to do this? Maybe some kernel32 functions?</p>