Vb.Net code to know the basic information of your computer.

A self explanatory windows form is design to to capture the all the basic details like:

  • Computer Name
  •  UserName
  • Operating System
  • Operating System version.
  • OS Platform
  • Network Connection
  • Monitor Height
  • Monitor width
  • Available physical memory
  • Total Physical Memory etc
Just design the windows form as shown below and writ down the code as show :

Public Class Computer_detail


    'declaration of variable
    Dim processName As String
    'declaration of DT variable as Datatable
    Dim DT As New DataTable
    Dim percent As Integer

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim availphyMem As Integer = My.Computer.Info.AvailablePhysicalMemory / 1000000
        Dim totlPhyMem As Integer = My.Computer.Info.TotalPhysicalMemory / 1000000
        Dim totVirtMem As Integer = My.Computer.Info.TotalVirtualMemory / 1000000
        'this line is for the name of computer
        Dim compname As String = My.Computer.Name
        'current username used on the machine
        Dim compuser As String = SystemInformation.UserName
        'display the Operating installedon this machine
        Dim OS As String = My.Computer.Info.OSFullName
        'show the platform of the operating installed
        Dim OSplatform As String = My.Computer.Info.OSPlatform
        'it display the Operating system version
        Dim osversion As String = My.Computer.Info.OSVersion
        'display the height and width of the machine
        Dim HeighMon As Integer = SystemInformation.PrimaryMonitorSize.Height
        Dim WidthMon As Integer = SystemInformation.PrimaryMonitorSize.Width

        'it loops trough all the processes happening running in this machine
        For Each p As Process In Process.GetProcesses
            'it display to the datagridview provided
        'it check if the machine is connectd to the network or not
        If My.Computer.Network.IsAvailable Then
            TxtNetworkConnection.Text = "Connected"
            TxtNetworkConnection.Text = "Not Connected"

        End If
        'it get and set the maximum value of progressbar
        ProgressBar1.Maximum = availphyMem
        ProgressBar1.Value = availphyMem
        'this is the formula to get the percentage
        percent = (ProgressBar1.Value / totlPhyMem) * 100
        'it display the percentage in the label
        blpercent.Text = percent & "%"

        'it assign and display all the data from the variable above
        'and display the corresponding value into the textboxes provided
        txtComputerName.Text = compname
        txtComputerUserName.Text = compuser
        txtos.Text = OS
        txtosplatform.Text = OSplatform
        txtosversion.Text = osversion
        txtTotalMemory.Text = availphyMem & " MB"
        txtAphysicalmemory.Text = totlPhyMem & " MB"
        txtvirtualmemory.Text = totVirtMem & " MB"
        ProgressBar1.Maximum = totlPhyMem
        txtMonitorHeight.Text = HeighMon
        txtMonitorwidth.Text = WidthMon

    End Sub

    Private Sub Computer_detail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'it starts the timer
        'create new column named "List of processes"
        DT.Columns.Add("List of Processe")
        'set the datasource of the datagridview to DT
        DataGridView1.DataSource = DT
    End Sub

End Class