dotnet-snippets.de
Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1410 | Anzahl registrierter User: 1443 | Besucher online: 264
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Partner von Codezone.de


Member of Microsoft Community Leader/Insider Program (CLIP)

Windows Version auslesen


Autor: ganymedes
Sprache: C#
Bewertung: 1,8
(1 Bewertung)

Anzahl der Aufrufe: 3760
  
Kick it on dotnet-kicks.de  

Beschreibung:

Gibt die Windows Version zurück

Abgelegt unter: Windows, Version, auslesen.



C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        public string GetVersionString()
        {
            OperatingSystem osInfo = System.Environment.OSVersion;
            string strVers = string.Empty;

            if (osInfo.Platform == PlatformID.Win32Windows)
            {
                // Windows 98 / 98SE oder Windows Me. Windows 95 unterstützt .NET nicht 
                if (osInfo.Version.Minor == 10) strVers = "Windows 98";
                if (osInfo.Version.Minor == 90) strVers = "Windows Me";
            }

            if (osInfo.Platform == PlatformID.Win32NT)
            {
                // Windows NT 4.0, 2000, XP oder Server 2003. Windows NT 3.51 unterstützt .NET nicht 
                if (osInfo.Version.Major == 4) strVers = "Windows NT 4.0";

                if (osInfo.Version.Major == 5)
                {
                    switch (osInfo.Version.Minor)
                    {
                        case 0: strVers = "Windows 2000"; break;
                        case 1: strVers = "Windows XP"; break;
                        case 2: strVers = "Windows Server 2003"; break;
                    }
                }
                if (osInfo.Version.Major == 6)
                {
                    if (osInfo.Version.Minor == 0)
                    {
                        strVers = "Vista/Win2008";
                    }
                }
            }

            strVers += " " + osInfo.ServicePack + ", Revision " + osInfo.Version.Revision.ToString() + ", " + osInfo.VersionString;

            if (strVers == "")
            {
                strVers = "Unbekannte Windows-Version";
            }

            return strVers;
        }
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)

Sperneder Patrick schrieb am:  17.07.2009 22:42:07

Interessanter Snippet, kenn ich irgendwo her.
Hat 'grosse' Ähnlichkeiten mit : http://dotnet-snippets.de/dns/os--servicepack-ermitteln-SID819.aspx


schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.