Re: Luck, or Unicode? Neither - just accurate coding to the API.
Small clarification however:
Windows 8.1 is still major version 6, so even the "fixed" code would run on it, ie if the code was "&& (OsVersion.dwMajorVersion >=5 && OsVersion.dwMajorVersion <= 6))" (which I'm sure was the intended code) would have run on anything from 2000 to 8.1. Only NT3.1-NT4.0 and Windows 10 would have been spared had the code not been buggy.
Windows 2000-2003 r2 = Major Version 5.
Windows Vista - Windows 8.1 = Major Version 6.
Windows 10 = Major Version 10.