In Visual Studio 2013 or higher, you can also use the new Version Helper functions.
There are methods for many different Windows versions. Example:
#include
if (!IsWindowsVistaOrGreater())
{
MessageBox(NULL, "You need at least Windows Vista", "Version Not Supported", MB_OK);
}
More information here