libusbx/libusbx — pull request #166 by photron (2013-12-18 22:57:08+00:00)
Title: Windows: Fix error formatting for SetupAPI errors

The [Guidelines for Using SetupAPI](http://msdn.microsoft.com/en-us/library/windows/hardware/ff545011.aspx) state that if a SetupAPI function fails then the return value of GetLastError() must be converted to a HRESULT value with the HRESULT_FROM_SETUPAPI macro before passing it to FormatMessage().

Without this translation FormatMessage() will not understand the SetupAPI error codes from SetupAPI functions and report ERROR_MR_MID_NOT_FOUND itself: "The system cannot find message text for message number 0x%1 in the message file for %2."

A new setupapi_error_str() function is added that takes care of the translation and calls windows_error_str() internally. This new function is called for SetupAPI errors instead of windows_error_str().

I came across this problem while trying to debug another problem and triggering a SetupAPI function to fail during this. Then FormatMessage() failed and I went to figure out why.