|C#||Visual Basic||Visual C++|
Public Shared Function SetConfiguration ( _ deviceHandle As MonoUsbDeviceHandle, _ configuration As Integer _ ) As Integer
The operating system may or may not have already set an active configuration on the device. It is up to your application to ensure the correct configuration is selected before you attempt to claim interfaces and perform other operations.
If you call this function on a device already configured with the selected configuration, then this function will act as a lightweight device reset: it will issue a SET_CONFIGURATION request using the current configuration, causing most USB-related device state to be reset (altsetting reset to zero, endpoint halts cleared, toggles reset).
You cannot change/reset configuration if your application has claimed interfaces - you should free them with ReleaseInterface(MonoUsbDeviceHandle, Int32) first. You cannot change/reset configuration if other applications or drivers have claimed interfaces.
A configuration value of -1 will put the device in unconfigured state. The USB specifications state that a configuration value of 0 does this, however buggy devices exist which actually have a configuration 0.
You should always use this function rather than formulating your own SET_CONFIGURATION control request. This is because the underlying operating system needs to know when such changes happen.
This is a blocking function.