Here is my first cut.
Remember that this is my first patch, so go easy on me with he flamethrowers. I know the indenting isn't quite right.
Probably easiest to review by comparing old and new rather than looking at old and patch.
Comments, especially regarding more appropriate error values to use, are welcome.
I think that, despite what Juan Lang advised, I need to detect version numbers as the FIXME can be triggered by perfecly legal use in XP/NT/?? but illegal code in ME/98/95. I am surprised that there is not some global enum-type variable containing a value that tells us which Windows we are pretending to be. There must be many more functions than this whose behaviour changed between OSes.
Peter