title: C# How to tell if DVD drive tray is open?
body: <p>I have a DVD reading and burning app in C#. I want to be able to detect the difference between an empty drive (no disk) and an open drive.</p>
  
  <p>Edit: After some more googling, I think a better problem description is "<strong>I want to access the drive tray status - open or closed</strong>"</p>
  
  <p>I can use</p>
  
  <pre><code>ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk WHERE DriveType= 5")
  </code></pre>
  
  <p>to find all the dvd drives in the system, and the properties tell me if there is a disk in the drive. <code>Access</code> property tells me if there is a blank disk.</p>
  
  <p>But <code>Access</code> is null when the drive is open, and when the drive is shut and empty. And I don't see any other property that changes when the drive opens or closes.</p>
  
  <p>Anyone know a way to distinguish an open drive from a closed and empty drive?</p>
  
  <p>I am using Win7, but ideally the solution would work on XP and Vista also.</p>