News for hackers. Stuff that matters.
Re:Changing the primary display using the Win32 API by moron4hire on Sunday June 12, 2022 @08:24AM (#31713969)
The documentation--the very links that OP provided--does say all of this. Look in the "Remarks" section of EnumDisplayDevices and ChangeDisplaySettings.
Re:Changing the primary display using the Win32 API by esprehn on Sunday June 12, 2022 @09:15AM (#31714234)
Yup, even with a code sample that addresses this situation:

https://docs.microsoft.com/en-us/windows/win32/api/winuser/n...

So the whole article is sort of "I reverse engineered software for fun instead of reading the docs"

It's a fun read about the quirks of the Windows API though.

Re:Changing the primary display using the Win32 API by michidk on Sunday June 12, 2022 @10:58AM (#31714977)
Oh. This is embarrassing! I totally disregarded the remarks section when reading through all the different system calls. This example is actually quite helpful and would have saved me from hours of research. Lesson learned, i guess.
Re:Changing the primary display using the Win32 API by the_only_law on Sunday June 12, 2022 @10:06AM (#31714588)
I don't blame them tbh, Microsoft seems to treat documentation that's not .NET as second class.

The Win32 documentation admittedly can be pretty good, when you can easily find what you're looking for. There's ben multiple times where I've gone looking for documentation for a still supported API only to be told "oh yeah the best option is to check out this old ass sample code from 2008"

Re:Changing the primary display using the Win32 API by legalcorrection on Sunday June 12, 2022 @10:17AM (#31714668)
2008 would be too long ago for web stuff, but in Windows land, that’s plenty recent. Win32 APIs are forever.
Re:Changing the primary display using the Win32 API by the_only_law on Sunday June 12, 2022 @10:18AM (#31714674)
A single code sample, that's probably poorly commented in my experience is hardly what I'd consider good documentation.

OTOH it's pretty easy to get help. People I know very skilled with the Windows API seems to be documentation themselves. I have seen RE guys casually bring up undocumented behavior of certain APIs off the top of their head.

Re:Changing the primary display using the Win32 API by wongarsu on Sunday June 12, 2022 @08:36AM (#31714028)
I always found the msdn documentation quite good, in the sense that almost every aspect of each API is described. However you have to read it thoroughly, a quick skim often leaves you doing things subtly wrong. I think that's where most people fail.

The API is often complex because of how old some parts are and how often things got extended in backwards-compatible ways

Re:Changing the primary display using the Win32 API by ogurechny on Sunday June 12, 2022 @09:32AM (#31714361)
Yep, doesn't seem to be an arcane knowledge: https://archive.org/details/windowsgraphicsp00juli/page/658/...

It would be more interesting to find out why the order of monitors changes “randomly” (computers can't really do anything randomly unless asked specifically). It could be something simple, like background driver updates that reset options they shouldn't reset, or the powered down state of monitors on boot, or video card enumerating connected devices differently, etc.