title: Enumerating Windows Portable Devices in C#
body: <p>I am attempting to enumerate connected portable devices on Windows using the Windows Portable Devices API and the PortableDeviceManager provided by this API. </p>
  
  <p>I have implemented enumeration of device IDs following the MSDN documentation <a href="http://msdn.microsoft.com/en-us/library/ms739461.aspx" rel="noreferrer">link</a> and various blogs <a href="http://cgeers.com/2011/05/22/enumerating-windows-portable-devices/" rel="noreferrer">link</a>, but they all result in the same issue - I can only get it to give me the ID of <em>one</em> device when there are several connected.</p>
  
  <p>Here's the snippet of C# code I am using:</p>
  
  <pre><code>PortableDeviceManagerClass deviceManager = new PortableDeviceManagerClass();
  deviceManager.RefreshDeviceList();  
  
  uint numberOfDevices = 1;            
  deviceManager.GetDevices(null, ref numberOfDevices);
  
  if (numberOfDevices == 0)
  {
      return new string[0];
  }
  
  string [] deviceIds = new string[numberOfDevices];
  deviceManager.GetDevices(ref deviceIds[0], ref numberOfDevices);
  
  return deviceIds;
  </code></pre>
  
  <p>I have two devices connected to my computer, one Removable USB memory stick and one digital camera. When both are active, only the device ID of my camera will be returned. When I deactivate the camera, the device ID of the removable USB stick is returned. </p>
  
  <p>Is there anyone with experience with this API which can point me in the direction of what I am doing wrong? </p>