using OSVERSIONINFOEX wSuiteMask in VS2008 C#

Posted on 2008-11-07
Last Modified: 2013-12-17
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



        private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);


        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

Question by:OrenRozen
    LVL 96

    Expert Comment

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

    LVL 96

    Expert Comment

    by:Bob Learned

    How to determine the Windows version by using Visual C#
    LVL 41

    Accepted Solution

    But that *is* returning the correct mask...
    274 (decimal) = 112 (hex) = which is the combination of the following SuiteMask values
    LVL 3

    Author Comment

    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.

    LVL 41

    Expert Comment

    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
    LVL 41

    Expert Comment

    ....find a table...

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now