Modern Windows 10 can run binaries that were compiled on 20 years ago for Windows 95 or NT4, however I imagine that the libraries that the code is calling would have changed massively since then.
I know that it is possible to maintain binary compatibility while further developing a library (in C++ for example by not adding any virtual member functions, not changing the size of a class/struct by reserving space for future use, etc.), but I imagine it requires a lot of forward planning and may cause updated code to be messy. Alternativley it is possible to retain old versions of libraries, but this is inefficient.
What have Microsoft done to maintain this binary compatibility in Windows for so long?