CheckMultisampleQualityLevels returns the number of quality levels, not the highest level.
If it returns "n" these levels are numbered 0 to n-1. For example if it returns 4 they are numbered 0, 1, 2, 3 - and if you want the highest one it's always one less than the number of levels