screeninfo icon indicating copy to clipboard operation
screeninfo copied to clipboard

"No enumerators available" - on Windows 10

Open feerrenrut opened this issue 4 years ago • 4 comments

Getting a No enumerators available error.

  • Windows 10
  • Python 3.7.3
  • screeninfo version - 0.6.3

The exception being raised in get_monitors is

Procedure probably called with not enough arguments (4 bytes missing)

This is coming from the EnumDisplayMonitors call in enumerators\windows

Originally posted by @feerrenrut in https://github.com/rr-/screeninfo/issues/27#issuecomment-611994044

feerrenrut avatar Apr 11 '20 14:04 feerrenrut

Do you get this error on older versions of screeninfo? Would you mind sharing what values the variable dc_full gets?

hhannine avatar Apr 11 '20 16:04 hhannine

I'm not reproducing this issue on Win10 with Python 3.8.1. @feerrenrut , would you either describe your setup in more detail or try python 3.8.1?

hhannine avatar Apr 11 '20 18:04 hhannine

This is the only version of screeninfo I have tried and on Python 3.7.3. I've worked around the issue in the application that was failing for me.

However, looking at this again I can see a few problems. Rectifying them fixes the issue for me.

  • For me, dc_full had a value of -16704030. The docs for GetDC specify that if it fails NULL will be returned. Rather than checking the value is greater than 0, it should be checked against None or 0 (I'd have to verify what ctypes does in this case)
  • The call to releaseDC is incorrect the docs for ReleaseDC suggest it should take two params int ReleaseDC( HWND hWnd, HDC hDC). Passing in ReleaseDC(None, dc_full) fixes the error for me.

feerrenrut avatar Apr 12 '20 15:04 feerrenrut

Thanks for looking into it. Would you mind posting your changes so I could test them? Or submit a PR? Since I can't reproduce the problem I can't do more right now.

hhannine avatar Apr 12 '20 15:04 hhannine