Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Afficher les information sur la version du Sytème d’exploitation

Modifier,ou,créer,une,source,d'événement
{filelink=15697}

using System;
using System.Runtime.InteropServices;
 
[StructLayout(LayoutKind.Sequential)]
class InfoSystemExp
{
 
    public int dwOSVersionInfoSize;
    public int dwMajorVersion;
    public int dwMinorVersion;
    public int dwBuildNumber;
    public int dwPlatformId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
    public String szCSDVersion;
}
 
class MainClass {
    [DllImport("kernel32.dll")]
    public static extern bool GetVersionEx([In, Out] InfoSystemExp osvi);
 
    static void Main(string[] args) {
        InfoSystemExp osvi = new InfoSystemExp();
        osvi.dwOSVersionInfoSize = Marshal.SizeOf(osvi);
 
        GetVersionEx(osvi);
 
        Console.WriteLine("Class size: " + osvi.dwOSVersionInfoSize);
        Console.WriteLine("Major Version: " + osvi.dwMajorVersion);
        Console.WriteLine("Minor Version: " + osvi.dwMinorVersion);
        Console.WriteLine("Build Number: " + osvi.dwBuildNumber);
        Console.WriteLine("Platform Id: " + osvi.dwPlatformId);
        Console.WriteLine("CSD Version: " + osvi.szCSDVersion);
        Console.WriteLine("Platform: " + Environment.OSVersion.Platform);
        Console.WriteLine("Version: " + Environment.OSVersion.Version);
 
    }
}

No comments yet.

Leave a Comment