title: libusb_open returns 'LIBUSB_ERROR_NOT_SUPPORTED' on Windows 7
body: <p>I have been developing USB drivers using LibUSB on Linux, but now I want to have one of my drivers compiled for Windows (this is the first time I am doing it).</p>
  <h3>My environment</h3>
  <p>I am working on Windows 7 using the <a href="http://en.wikipedia.org/wiki/MinGW" rel="noreferrer">MinGW</a> compiler (also using Dev-cpp IDE), and I am using a pre-compiled libusb library downloaded from <a href="http://garr.dl.sourceforge.net/project/libusbx/releases/1.0.16/binaries/libusbx-1.0.16-rc1-win.7z" rel="noreferrer">this link</a>.</p>
  <p><strong>My device:</strong> It's a HID touch device. So no drivers are required for Windows. I have an additional endpoint to get certain debug data.</p>
  <h3>My code:</h3>
  <p>I have compiled code to list all the devices and USB devices connected to my machine, and the code works. Now I add code to open the device so that I get a device handle and start communication. But the function returns -12 That is, <em>LIBUSB_ERROR_NOT_SUPPORTED</em>.</p>
  <p>How can I fix this problem?</p>
  <p>I searched through the Internet and did not find a definite solution for this problem. While it's code which works beautifully on Linux.</p>
  <p><strong>P.S.:</strong> I have added the whole code below. The <code>DoList();</code> function works fine, but the <code>GetTRSDevice();</code> function fails at  <code>libusb_open(dev, &amp;handle);</code>.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;libusb.h&gt;
  
  
  libusb_device_handle* deviceHandle = NULL;
  
  int DoList();
  libusb_device_handle* GetTRSDevice(void);
  
  int main()
  {
      int ret = libusb_init(NULL);
      if (ret &lt; 0) {
          printf(&quot;Failed to init libusb&quot;);
          return ret;
      }
  
      DoList();
      deviceHandle = GetTRSDevice();
      if(!deviceHandle) {
          printf(&quot;Failed to locate device&quot;);
          goto fail_dev_open;
      }
  
      printf(&quot;Device opened&quot;);
  
      libusb_close(deviceHandle);
      fail_dev_open:
          libusb_exit(NULL);
  
      return(ret);
  }
  
  int DoList()
  {
      libusb_device **devs;
      ssize_t cnt;
  
  
      cnt = libusb_get_device_list(NULL, &amp;devs);
      if (cnt &lt; 0)
          return (int) cnt;
  
      libusb_device *dev;
      int i = 0;
  
      while ((dev = devs[i++]) != NULL) {
          struct libusb_device_descriptor desc;
          int r = libusb_get_device_descriptor(dev, &amp;desc);
          if (r &lt; 0) {
              fprintf(stderr, &quot;failed to get device descriptor&quot;);
              return(-1);
          }
  
          printf(&quot;%04x:%04x (bus %d, device %d)\n&quot;,
                 desc.idVendor, desc.idProduct,
                 libusb_get_bus_number(dev), libusb_get_device_address(dev));
      }
      libusb_free_device_list(devs, 1);
      return 0;
  }
  
  libusb_device_handle* GetTRSDevice(void)
  {
      int i = 0;
      ssize_t cnt;
      libusb_device *dev;
      libusb_device **devs;
      libusb_device_handle* handle = NULL;
  
      cnt = libusb_get_device_list(NULL, &amp;devs);
      if (cnt &lt; 0) {
          printf(&quot;Failed libusb_get_device_list&quot;);
          return(0);
      }
  
      while ((dev = devs[i++]) != NULL) {
          struct libusb_device_descriptor desc;
          int ret = libusb_get_device_descriptor(dev, &amp;desc);
          if (ret &lt; 0) {
              printf(&quot;Failed libusb_get_device_descriptor&quot;);
              continue;
          }
          if(desc.idVendor == 0X238f &amp;&amp; desc.idProduct == 1) {
              int ret = libusb_open(dev, &amp;handle);
              if (ret &lt; 0) {
                  printf(&quot;Failed libusb_open: %d\n\r&quot;,ret);
                  break;
              }
              #ifndef WIN32
                  libusb_detach_kernel_driver(handle, 0);
              #endif
              ret = libusb_claim_interface(handle,0);
              if (ret &lt; 0) {
                  libusb_close(handle);
                  handle=NULL;
                  break;
              }
              break;
          }
      }
      libusb_free_device_list(devs, 1);
      return(handle);
  }
  </code></pre>