使うことなんてないと思うけれど、一応メモ。
Windows系コンパイラなら問題なくコンパイルできると思う。
一応、MinGWでコンパイル、動作確認は行った。
#include <windows.h>
#include <stdio.h>
int main(void)
{
unsigned int GV = GetVersion();
printf("GetVersion API(GV) = %08X\n\n", GV);
printf("_winver = %08X\n", _winver);
printf("_winmajor = %08X\n", _winmajor);
printf("_winminor = %08X\n", _winminor);
printf("_osver = %08X\n\n", _osver);
printf("(( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF = %08X (= _winver)\n",
(( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF );
printf("GV & 0XFF = %08X (= _winmajor)\n",
GV & 0XFF );
printf("( GV >> 8 ) & 0XFF = %08X (= _winminor)\n",
(( GV >> 8 ) & 0XFF));
printf("GV >> 16 = %08X (= _osver)\n\n\n",
(GV >> 16) );
// Windows version(_winmajor, _winminor, _osver)
printf("This system is [");
if ( _osver < 0X8000 ) {
// NT Group (_osver LowWORD MSB = 0)
switch (_winmajor) {
case 3:
case 4:
printf ("Windows NT %u.%u Build %u",
_winmajor, _winminor, _osver);
break;
case 5:
switch (_winminor) {
case 0:
printf ("Windows 2000 Build %u", _osver);
break;
case 1:
printf ("Windows XP Build %u", _osver);
break;
case 2:
printf ("Windows Server 2003 family Build %u",
_osver);
break;
default:
printf ("NT Group Windows Build %u", _osver);
}
break;
case 6:
switch (_winminor) {
case 0:
printf ("Windows Vista or Windows Server 2008 Build %u", _osver);
break;
case 1:
printf ("Windows 7 Build %u", _osver);
break;
default:
printf ("NT Group Windows Build %u", _osver);
}
break;
default:
printf ("NTGroup Windows Build %u", _osver);
}
}
else {
switch (_winmajor ) {
case 0: //Win32s Group
case 1:
case 2:
case 3:
printf ("Win32s Build %u", _osver & 0X7FFF);
break;
case 4: // 9X Group (_osver is invalid.)
switch (_winminor) {
case 0:
printf ("Windows 95 Build ----");
break;
case 10:
printf ("Windows 98 Build ----");
break;
case 90:
printf ("Windows Me Build ----");
break;
default: // To make sure
printf ("Newer than Windows Me");
}
break;
default: // To make sure
printf ("Newer than Windows Me");
}
}
printf("]");
return 0;
}