title: Blocking a USB Device using SetupDiCallClassInstaller takes long time
body: <p>&nbsp;I created an application to block USB devices using SetupDiCallClassInstaller function. 
  <br><br>But in some OS, the blocking process takes only 1 or 2 secs to block the inserted device. Here blocking refers to disabling the USB devices.
  <br><br>In some OS, it takes 30 secs to 2 minutes to block a USB Devices.
  <br><br>
  Here I shared some part of my code :</p>
  
  <pre><code>    SP_PROPCHANGE_PARAMS spPropChangeParams;
      spPropChangeParams.StateChange = DICS_DISABLE;
      spPropChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
      spPropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE ;
      spPropChangeParams.Scope = DICS_FLAG_GLOBAL ;
      spPropChangeParams.HwProfile = 0; // current hardware profile
  
      printf("Time Before Blocking Device : %s\n",GetCurrTime());
  
      if(SetupDiSetClassInstallParams(m_hDevInfo, &amp;m_DeviceInfoData,(SP_CLASSINSTALL_HEADER*)&amp;spPropChangeParams, sizeof(SP_PROPCHANGE_PARAMS))== FALSE )
      {
          printf("Not able to manage the status of the device.SetupDiSetClassInstallParams Failed at ErrorCode - %ld\n",GetLastError());
      }
  
      else if(!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,m_hDevInfo, &amp;m_DeviceInfoData))
      {
          DWORD error = GetLastError();
          printf("Not able to manage the status of the device.SetupDiCallClassInstaller API Failed at Errorcode - %ld\n",error);
          {
              if(error == 13)
              {
                  for(int i=0;i&lt; RETRY_TIME ;i++)
                  {
                      if(SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,m_hDevInfo, &amp;m_DeviceInfoData))
                      {
                          printf("retry succeeded for disabling device\n");
                          break;
                      }
                      printf("retry failed for disabling device\n");  
                      Sleep(20);
                  }
              }
          }
      }
  
      printf("Time After Blocking Device : %s\n",GetCurrTime());
  </code></pre>
  
  <blockquote>
    <p>OUTPUT is:</p>
    
    <p>Time Before Blocking Device : 18:57:48<br>
    Time After Blocking Device : 18:59:18</p>
    
    <hr>
    
    <p>Here, it takes 1.30 minutes to block the device.</p>
  </blockquote>
  
  <p><strong>Note :</strong> Once the device is blocked(i.e.)disabled. Then I go to Device Manager and I enable the Device which is disabled. Then again it takes long time to block that devices.
  <br>
  <br>Kindly revert back for any clarifications.
  <br>Thanks and Regards,
  <br>AK</p>