title: How does one programmatically mount a drive in Windows?
body: <p>We make and sell a device that our users will sometimes want to connect to their computer in large quantities with multiple USB hubs. It is a USB composite device that has both human interface (HID) and mass storage (MSD) interfaces. Windows automatically mounts the file-system of each device until it runs out of letters at 'Z:'.</p>
  
  <p>I can walk the device tree and get the device instance identifiers for the HID and USBSTOR interfaces using a combination of the <a href="http://msdn.microsoft.com/en-us/library/ff549717%28VS.85%29.aspx" rel="nofollow">PnP Configuration Manager</a> and <a href="http://msdn.microsoft.com/en-us/library/ff541299%28VS.85%29.aspx" rel="nofollow">Device Installation</a> functions. With the USB storage device path I can also get the disk number (i.e. <code>\\.\PhysicalDrive1</code>).</p>
  
  <p>The next step would be to mount these disks as need by cycling out drive letters as we communicate with the devices, or better yet, mount them in temporary directories on the C: drive. I'm having difficulties attempting to use <a href="http://msdn.microsoft.com/en-us/library/aa363904%28VS.85%29.aspx" rel="nofollow">DefineDosDevice</a> for this task and cannot make headway with <a href="http://msdn.microsoft.com/en-us/library/aa365561%28VS.85%29.aspx" rel="nofollow">SetVolumeMountPoint</a> since a device does not have a <a href="http://msdn.microsoft.com/en-us/library/aa365248%28VS.85%29.aspx" rel="nofollow">Volume GUID</a> until it is mounted. That presents a chicken and egg problem.</p>
  
  <p><em>If only our customers used unix!!!</em></p>