Is there any way to get more detailed error reports from a windows API call?

90 views Asked by At

I'm working on a pretty large program that makes calls to ChangeDisplaySettingsEx in order to change the layout/resolution around of displays.

I've been running into issues where these calls sometimes work and sometimes they don't, and I can't determine what's causing the failures.

Whenever it fails, I get a return code of -1 which corresponds to DISP_CHANGE_FAILED which clearly is not very descriptive.

I'm wondering if there's any better way to debug the result of the call so I can tell what's causing it to fail?

1

There are 1 answers

3
πάντα ῥεῖ On

"I'm wondering if there's any better way to debug the result of the call so I can tell what's causing it to fail?"

You may try to query the actual displays capabilities beforehand, as recommended in the reference documentation:

Remarks

"To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function."

After doing so you can compare the returned DEVMODE with what you've tried to pass as settings.