LAPICALL GetError(LPWSTR buffer, int bufferBytes);

Retrieves the last error. buffer contains the address of a buffer that receives the error description. bufferBytes contains the number of bytes in the buffer. When an API function fails, you must call this function immediately without calling any other function.