using OSVERSIONINFOEX wSuiteMask in VS2008 C#

I'm trying in this code to get the Os edition running on.

the return using GetOsEd is 272 when running on server 2003 standard  SP2 32bit
and 274 when running on server 2003 enterprise SP2 32bit

why don't i get the correct return codes?

public class OsInfo
    {
        [DllImport("kernel32.dll")]
        private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
 
        [StructLayout(LayoutKind.Sequential)]
        private struct OSVERSIONINFOEX
        {
            public int dwOSVersionInfoSize;
            public int dwMajorVersion;
            public int dwMinorVersion;
            public int dwBuildNumber;
            public int dwPlatformId;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
            public string szCSDVersion;
            public short wServicePackMajor;
            public short wServicePackMinor;
            public short wSuiteMask;
            public byte wProductType;
            public byte wReserved;
        }
 
        private const Int32 VER_SUITE_SMALLBUSINESS = 1;
        private const Int32 VER_SUITE_ENTERPRISE = 2;
        private const Int32 VER_SUITE_TERMINAL = 16;
        private const Int32 VER_SUITE_DATACENTER = 128;
        private const Int32 VER_SUITE_SINGLEUSERTS = 256;
        private const Int32 VER_SUITE_PERSONAL = 512;
        private const Int32 VER_SUITE_BLADE = 1024;
 
        public static string GetOsEd()
        {
            OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
            osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(osVersionInfo);
            GetVersionEx(ref osVersionInfo);
 
            return osVersionInfo.wSuiteMask.ToString();
        }
 
    }

Open in new window

LVL 3
OrenRozenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
You can use the Environment class to get operating system information:

            Environment.OSVersion.Platform
            Environment.OSVersion.ServicePack
            Environment.OSVersion.Version.Major
            Environment.OSVersion.Version.Minor
            Environment.OSVersion.Version.Revision
            Environment.OSVersion.Version.Build
0
Bob LearnedCommented:
Reference:

How to determine the Windows version by using Visual C#
http://support.microsoft.com/kb/304283
0
grayeCommented:
But that *is* returning the correct mask...
274 (decimal) = 112 (hex) = which is the combination of the following SuiteMask values
VER_SUITE_SINGLEUSERTS (0x100) + VER_SUITE_TERMINAL (0x10) + VER_SUITE_ENTERPRISE (0x2)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

OrenRozenAuthor Commented:
Appreciate your fat respond.

will 274 always return for enterprise and 272 for standard?

Is there a decimal/hex table for all 2003 and 2008 edition with the
different combination's as shown in your answer?

the following link list hex values but 112 or 110 isn't in that list.
http://msdn.microsoft.com/en-us/library/ms724833(VS.85).aspx

Thanks,
0
grayeCommented:
So, 110 = VER_SUITE_SINGLEUSERTS (0x100) + VER_SUITE_TERMINAL (0x10).   Or, to put it another way:  0x100 + x10 = 0x110
I wouldn't bother trying to file a table of every possible value (that's 169 possible combinations)... instead I'd suggest that you "do the math" using the hex values.   That link has all of the possible values (in Hex) that can be combined together
0
grayeCommented:
....find a table...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.