Version Check again and again

Developers care about job security. They have to. In my conspiracy theories, the Y2K bug was an evil plan by a group of developers that saw their 401k's take a nose dive and they wanted a backup plan for retirement. Without too much investment, that is.

I came across the version check issue again today. A complicated application with multiple instances launching themselves, talking to services, creating events etc. error-ed out with a let's say, non-descriptive error message. Considering the architecture I was expecting either UAC, MIC or Session 0 isolation as the culprit. But no. After an hour of two debugging (my, how much easier is user mode debugging than kernel mode), the culprit was (in pseudocode and simplified):

dwVersion = GetVersion();

if ( dwVersion == 5 )
    name = "this";

if ( dwVersion == 4 )

    name = "that";

And that was it. No 6. No 5 and up.

By the way, check the notes in GetVersionEx(). It is not always the best approach to check the version, checking for availability of a feature might be more desirable. Reason is that features might be added (or removed). But then again, for job security…