Advertisement
Guillaume17

[VB.net] Windows information

Oct 25th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.33 KB | None | 0 0
  1. Imports System
  2.  
  3. Public Class Form1
  4.  
  5.     'Version de windows complète
  6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7.         TextBox1.Text = "Version du système d'exploitation : " & Environment.OSVersion.ToString()
  8.     End Sub
  9.  
  10.     'Version de windows 32 ou 64 bits
  11.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  12.         Dim rt As String = ""
  13.         If Environment.Is64BitOperatingSystem = True Then
  14.             rt = "Vous avez un Windows 64 bits"
  15.         Else
  16.             rt = "Vous avez un Windows 32 bits"
  17.         End If
  18.         Textbox2.text = rt
  19.     End Sub
  20.  
  21.     'Version de windws simplifiée
  22.     Private Function GetBitVersion() As String
  23.         Return IIf(Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Hardware\Description\System\CentralProcessor\0").GetValue("Identifier").ToString().Contains("x86"), "32 bit", "64 bit")
  24.     End Function
  25.     Private Function GetWindowsVersion() As String
  26.         If Environment.OSVersion.Platform = PlatformID.Win32Windows Then
  27.             Return IIf(Environment.OSVersion.Version.Minor = 10, "Windows 98", "Windows ME")
  28.         Else
  29.             Select Case Environment.OSVersion.Version.Major
  30.                 Case 4
  31.                     Return "Windows NT 4.0"
  32.                 Case 5
  33.                     Select Case Environment.OSVersion.Version.Minor
  34.                         Case 0
  35.                             Return "Windows 2000"
  36.                         Case 1
  37.                             Return "Windows XP"
  38.                         Case 2
  39.                             Return "Windows Server 2003"
  40.                     End Select
  41.                     Exit Select
  42.                 Case 6
  43.                     Return IIf(Environment.OSVersion.Version.Minor = 0, "Windows Vista", "Windows 7")
  44.             End Select
  45.         End If
  46.         Return "Système d'exploitation inconnu"
  47.     End Function
  48.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  49.         textbox3.text = GetWindowsVersion()
  50.     End Sub
  51.  
  52.     'Nombre de bits
  53.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  54.         TextBox4.Text = GetBitVersion()
  55.     End Sub
  56. End Class
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement