My take on this is this:
A key thing to do is to never rely on undocumented behaviour. Never.
These undocumented features are undocumented for a reason, and the least of it is that they can change "unexpectedly". But you have no excuse - undocumented features are prone to change, they are almost meant to change, so never rely on them.
Make your program "less clever" but rely on a few clearly documented and main line features. That includes avoiding the "special" and "advanced" features - just stay mainline, it will enhance code clarity and maintenance drastically.
The other thing to avoid is so called "3rd party" components. In Windows development, avoid reliance on a variety of 3rd party controls and components.Who knows what assumptions they were built on (and which undocumented features THEY used)?
Done this way, it is possible to define a clear baseline which makes a program work when those baseline requirements are met.
If those requirements are few (and are sufficiently mainline and thus likely to be maintained in the future by vendors and OS developers), then you have the key to future workability.
Keep Up with TechRepublic