Q: How to get the reason for a failure of a SDK function?

A: First of all, take a look in MSDN and read the documentation of the function. See the meaning of the returned value.

Most Windows...