You'd better use simply the WinApi for this purpose.
Try GetVersionEx. See
here
EDIT:
This is how you get the version from the registry:
LPCTSTR version;
HKEY hKey;
if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
TCHAR szData[256];
DWORD dwKeyDataType;
DWORD dwDataBufSize = 256;
if (::RegQueryValueEx(hKey, _T("CurrentVersion"), NULL, &dwKeyDataType, (BYTE*) &szData, &dwDataBufSize) == ERROR_SUCCESS)
{
if(dwKeyDataType == REG_SZ)
{
version = szData;
}
}
}
Here's the mapping for the version numbers
Operating system Version number
----------------- --------------
Windows 8 6.2
Windows Server 2012 6.2
Windows 7 6.1
Windows Server 2008 R2 6.1
Windows Server 2008 6.0
Windows Vista 6.0
Windows Server 2003 R2 5.2
Windows Server 2003 5.2
Windows XP 64-Bit Edition 5.2
Windows XP 5.1
Windows 2000 5.0
I hope this was helpful