title: My SetupDiEnumDeviceInterfaces is not working
body: <p>I am interested to find out if I am doing this right:</p>
  
  <pre><code>//DeviceManager.h
  #include &lt;windows.h&gt;
  //#include &lt;hidsdi.h&gt;
  #include &lt;setupapi.h&gt;
  #include &lt;iostream&gt;
  #include &lt;cfgmgr32.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;devpkey.h&gt;
  
  extern "C"{
      #include &lt;hidsdi.h&gt;
  }
  
  //#pragma comment (lib, "setupapi.lib")
  
  class DeviceManager
  {
  public:
      DeviceManager();
      ~DeviceManager();
  
      void ListAllDevices();
      void GetDevice(std::string vid, std::string pid);
  
      HANDLE PSMove;
      byte reportBuffer;
  private:
      HDEVINFO deviceInfoSet;             //A list of all the devices
      SP_DEVINFO_DATA deviceInfoData;     //A device from deviceInfoSet
  
      SP_DEVICE_INTERFACE_DATA deviceInterfaceData;
      SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailedData;
  
  };
  
  //DeviceManager.cpp
  #include"DeviceManager.h"
  
  DeviceManager::DeviceManager()
  {
      deviceInfoSet = SetupDiGetClassDevs(NULL, TEXT("USB"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES); //Gets all Devices
  }
  
  DeviceManager::~DeviceManager()
  {
  }
  
  void DeviceManager::ListAllDevices()
  {
      DWORD deviceIndex = 0;
  
      deviceInfoData.cbSize = sizeof(deviceInfoData);
  
      while(SetupDiEnumDeviceInfo(deviceInfoSet, deviceIndex, &amp;deviceInfoData))
      {
          deviceInfoData.cbSize = sizeof(deviceInfoData);
  
          ULONG tcharSize;
          CM_Get_Device_ID_Size(&amp;tcharSize, deviceInfoData.DevInst, 0);
          TCHAR* deviceIDBuffer = new TCHAR[tcharSize];   //the device ID will be stored in this array, so the tcharSize needs to be big enough to hold all the info.
                                                          //Or we can use MAX_DEVICE_ID_LEN, which is 200
  
          CM_Get_Device_ID(deviceInfoData.DevInst, deviceIDBuffer, MAX_PATH, 0); //gets the devices ID - a long string that looks like a file path.
  
          /*
          //SetupDiGetDevicePropertyKeys(deviceInfoSet, &amp;deviceInfoData, &amp;devicePropertyKey, NULL, 0, 0);
          if( deviceIDBuffer[8]=='8' &amp;&amp; deviceIDBuffer[9]=='8' &amp;&amp; deviceIDBuffer[10]=='8' &amp;&amp; deviceIDBuffer[11]=='8' &amp;&amp; //VID
              deviceIDBuffer[17]=='0' &amp;&amp; deviceIDBuffer[18]=='3' &amp;&amp; deviceIDBuffer[19]=='0' &amp;&amp; deviceIDBuffer[20]=='8') //PID
          {
              std::cout &lt;&lt; deviceIDBuffer &lt;&lt; "\t&lt;-- Playstation Move" &lt;&lt; std::endl;
          }
          else
          {
              std::cout &lt;&lt; deviceIDBuffer &lt;&lt; std::endl;
          }*/
  
          std::cout &lt;&lt; deviceIDBuffer &lt;&lt; std::endl;
  
          deviceIndex++;
      }
  }
  
  void DeviceManager::GetDevice(std::string vid, std::string pid)
  {
  
      DWORD deviceIndex = 0;
      deviceInfoData.cbSize = sizeof(deviceInfoData);
  
      while(SetupDiEnumDeviceInfo(deviceInfoSet, deviceIndex, &amp;deviceInfoData))
      {
          deviceInfoData.cbSize = sizeof(deviceInfoData);
  
          ULONG IDSize;
          CM_Get_Device_ID_Size(&amp;IDSize, deviceInfoData.DevInst, 0);
  
          TCHAR* deviceID = new TCHAR[IDSize];
  
          CM_Get_Device_ID(deviceInfoData.DevInst, deviceID, MAX_PATH, 0);
  
          if( deviceID[8]==vid.at(0) &amp;&amp; deviceID[9]==vid.at(1) &amp;&amp; deviceID[10]==vid.at(2) &amp;&amp; deviceID[11]==vid.at(3) &amp;&amp; //VID
              deviceID[17]==pid.at(0) &amp;&amp; deviceID[18]==pid.at(1) &amp;&amp; deviceID[19]==pid.at(2) &amp;&amp; deviceID[20]==pid.at(3)) //PID
          {
              //DWORD requiredBufferSize;
              //SetupDiGetDeviceInterfaceDetail(deviceInfoSet, &amp;deviceInterfaceData, NULL, 0, &amp;requiredBufferSize, 
  
  
              HDEVINFO deviceInterfaceSet = SetupDiGetClassDevs(&amp;deviceInfoData.ClassGuid, NULL, NULL, DIGCF_ALLCLASSES);
  
              DWORD deviceInterfaceIndex = 0;
              deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
              while(SetupDiEnumDeviceInterfaces(deviceInterfaceSet, NULL, &amp;deviceInterfaceData.InterfaceClassGuid, deviceInterfaceIndex, &amp;deviceInterfaceData))
              {
                  deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
                  std::cout &lt;&lt; deviceInterfaceIndex &lt;&lt; std::endl;
  
                  deviceInterfaceIndex++;
              }
  
              //std::cout &lt;&lt; deviceInterfaceData.cbSize &lt;&lt; std::endl;
  
              break;
          }
  
          deviceIndex++;
      }
  }
  </code></pre>
  
  <p>My SetupDiEnumDeviceInterfaces (in the GetDevice() function) is not doing anything. It is not even entering the while loop. What is it that I'm doing wrong?</p>
  
  <h2>Edit</h2>
  
  <p>I've just called the GetLastError() function and it has returned a 259 - ERROR_NO_MORE_ITEMS. Is it even possible for a device to contain no interfaces?</p>