GetVersion (kernel32)
Last changed: -125.239.167.15

.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern uint GetVersion();

User-Defined Types:

None.

Notes:

Retrieves the version number of the current operating system

Tips & Tricks:

Please add some!

Sample Code:

using System;

using System.Text;

using System.Runtime.InteropServices;

namespace testt

{

    class Program
    {
    static void Main(string[] args)
    {
        StringBuilder str = new StringBuilder(100);
        uint dwWersion = WinAPI.GetVersion();

        str.Append(WinAPI.LoByte((ushort)WinAPI.LoWord(dwWersion)));
        str.Append(".");
        str.Append(WinAPI.HiByte((ushort)WinAPI.LoWord(dwWersion)));
        if (dwWersion < 0x80000000)
        {
        str.Append("." + WinAPI.HiWord(dwWersion).ToString());
        }
        Console.WriteLine("OS Version is " + str.ToString());
    }
    }

    static class WinAPI
    {
    public static uint LoWord(uint dwValue)
    {
        return dwValue & 0xFFFF;
    }

    public static uint HiWord(uint dwValue)
    {
        return (dwValue >> 16) & 0xFFFF;
    }

    public static ushort LoByte(ushort wValue)
    {
        return (ushort)(wValue & 0xFF);
    }

    public static ushort HiByte(ushort wValue)
    {
        return (ushort)((wValue >> 8) & 0xFF);
    }

    [DllImport("kernel32.dll")]
    public static extern uint GetVersion();
    }

}

Alternative Managed API:

GetVersionEx(), Operating System Version(), VerifyVersionInfo()

Documentation
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx">GetVersion</href>@msdn on MSDN