{"id":6181,"date":"2010-04-30T21:19:38","date_gmt":"2010-04-30T19:19:38","guid":{"rendered":"http:\/\/funrecycler.com\/?p=6181"},"modified":"2010-04-30T21:19:38","modified_gmt":"2010-04-30T19:19:38","slug":"vb-net-windows-version-erkennen","status":"publish","type":"post","link":"https:\/\/funrecycler.com\/index.php\/2010\/04\/30\/vb-net-windows-version-erkennen\/","title":{"rendered":"VB.net &#8211; Windows Version erkennen"},"content":{"rendered":"<p><a href=\"http:\/\/funrecycler.com\/wp-content\/uploads\/2010\/04\/windowsversion.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-6202\" style=\"margin: 10px;\" title=\"windowsversion\" src=\"http:\/\/funrecycler.com\/wp-content\/uploads\/2010\/04\/windowsversion.png\" alt=\"\" width=\"299\" height=\"73\" \/><\/a><br \/>\nWenn man ein Programm mit Vb.net erstellt, ist es in den meisten F\u00e4llen nicht notwendig, die Windows Version abzufragen, auf welchen das Programm ausgef\u00fchrt wird. Doch programmiert man ein Tool\/Programm was auf spezielle Funktionen zur\u00fcckgreift, die nur in von einer bestimmten Windows Version unterst\u00fctzt werden, so ist es ganz praktisch beim Programmstart die Version in Erfahrung zu bringen.<br \/>\nDa .net hier sehr viele Funktionen bietet um Systeminformationen abzufragen, ist dies mit einer kleinen Funktion sehr schnell erledigt.<br \/>\n\u00dcber den System Zugriff: System.Environment.OSVersion erh\u00e4lt man als R\u00fcckgabewert eine Nummer. Entsprechende Unterabfragen wie platform, major und minor liefern weitere Zahlen, mit welchen sich durch Kombination das Betriebssystem ermitteln l\u00e4sst.<br \/>\nIn der MSDN Online Bibliothek kann man nachlesen welche Nummer\/Kombination welchen Betriebssystem entspricht.<\/p>\n<table border=\"1\" width=\"100%\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">Windows 98<\/td>\n<td style=\"text-align: center;\">Windows Me<\/td>\n<td style=\"text-align: center;\">Windows NT 4.0<\/td>\n<td style=\"text-align: center;\">Windows 2000<\/td>\n<td style=\"text-align: center;\">Windows XP<\/td>\n<td style=\"text-align: center;\">Windows Server 2003<\/td>\n<td style=\"text-align: center;\">Windows Vista \/2008 Server<\/td>\n<td style=\"text-align: center;\">Windows 7<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Platform<\/td>\n<td style=\"text-align: center;\">1<\/td>\n<td style=\"text-align: center;\">1<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<td style=\"text-align: center;\">2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Version.Major<\/td>\n<td style=\"text-align: center;\">4<\/td>\n<td style=\"text-align: center;\">4<\/td>\n<td style=\"text-align: center;\">4<\/td>\n<td style=\"text-align: center;\">5<\/td>\n<td style=\"text-align: center;\">5<\/td>\n<td style=\"text-align: center;\">5<\/td>\n<td style=\"text-align: center;\">6<\/td>\n<td style=\"text-align: center;\">6<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Version.Minor<\/td>\n<td style=\"text-align: center;\">10<\/td>\n<td style=\"text-align: center;\">90<\/td>\n<td style=\"text-align: center;\">0<\/td>\n<td style=\"text-align: center;\">0<\/td>\n<td style=\"text-align: center;\">1<\/td>\n<td style=\"text-align: center;\"><\/td>\n<td style=\"text-align: center;\">?<\/td>\n<td style=\"text-align: center;\">?<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--more-->In der Funktion lassen sich \u00fcber Select Case Anweisungen das Betriebssystem &#8222;filtern&#8220;.<\/p>\n<pre lang=\"VB\">Public Function func_read_windows_version<\/pre>\n<p>Funktion definieren<\/p>\n<pre lang=\"VB\">Dim os_version As System.OperatingSystem = System.Environment.OSVersion\nDim os_is_version As String<\/pre>\n<p>OS Version auslesen und in eine Variable speichern, os_is_version als R\u00fcckgabevariable definieren<\/p>\n<pre lang=\"VB\">With os_version\nSelect Case .platform\n  Case .platform.win32windows\n    Select Case (.Version.Minor)\n      Case 0\n        os_is_version = \"Windows 95\"\n      Case 10\n\tIf .version.revision.tostring() = \"2222A\" Then\n\t  os_is_version = \"Windows 98 - Second Edition\"\n\tElse\n\t  os_is_version = \"Windows 98\"\n\tEnd If\n      Case 90\n\t  os_is_version = \"Windows Me\"\n    End Select<\/pre>\n<p>Platform bestimmen = DOS Basis<\/p>\n<pre lang=\"VB\">Case .platform.win32nt\n  Select Case (.Version.Major)\n    Case 3\n      os_is_version = \"Windows NT 3.51\"\n    Case 4\n      os_is_version = \"Windows NT 4.0\"\n    Case 5\n      Select Case (.Version.Minor)\n        Case 0\n\t  os_is_version = \"Windows 2000\"\n\tCase 1\n\t  os_is_version = \"Windows XP\"\n\tCase 2\n\t  os_is_version = \"Windows 2003 Server\"\n      End Select\n    End Select\n  End Select\nEnd With<\/pre>\n<p>Platform bestimmen = NT Basis<\/p>\n<pre lang=\"VB\">return os_is_version\nEnd Function<\/pre>\n<p>R\u00fcckgabe der Version<br \/>\nDie komplette Funktion sieht wie folgt aus:<\/p>\n<pre lang=\"VB\">Public Function func_read_windows_version\nDim os_version As System.OperatingSystem = System.Environment.OSVersion\nDim os_is_version As String\nWith os_version\nSelect Case .platform\n  Case .platform.win32windows\n    Select Case (.Version.Minor)\n      Case 0\n        os_is_version = \"Windows 95\"\n      Case 10\n\tIf .version.revision.tostring() = \"2222A\" Then\n\t  os_is_version = \"Windows 98 - Second Edition\"\n\tElse\n\t  os_is_version = \"Windows 98\"\n\tEnd If\n      Case 90\n\t  os_is_version = \"Windows Me\"\n    End Select\nCase .platform.win32nt\n  Select Case (.Version.Major)\n    Case 3\n      os_is_version = \"Windows NT 3.51\"\n    Case 4\n      os_is_version = \"Windows NT 4.0\"\n    Case 5\n      Select Case (.Version.Minor)\n        Case 0\n\t  os_is_version = \"Windows 2000\"\n\tCase 1\n\t  os_is_version = \"Windows XP\"\n\tCase 2\n\t  os_is_version = \"Windows 2003 Server\"\n      End Select\n    End Select\n  End Select\nEnd With\nreturn os_is_version\nEnd Function<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Wenn man ein Programm mit Vb.net erstellt, ist es in den meisten F\u00e4llen nicht notwendig, die Windows Version<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,14],"tags":[2815,2824,2825,2827,2828,3009],"class_list":["post-6181","post","type-post","status-publish","format-standard","hentry","category-computer-und-technik","category-programmieren","tag-vbnet","tag-vb-net-win","tag-vb-net-win-version","tag-vb-net-windows-version","tag-vb-net-windows-version-ermitteln","tag-windows-version"],"_links":{"self":[{"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/posts\/6181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/comments?post=6181"}],"version-history":[{"count":0,"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/posts\/6181\/revisions"}],"wp:attachment":[{"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/media?parent=6181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/categories?post=6181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/funrecycler.com\/index.php\/wp-json\/wp\/v2\/tags?post=6181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}