How to know the configuration of the computer in VB.NET

Dani AI

Generated

asked how to read a machine's configuration and correctly pointed to the VB helpers as a quick start. For more control, two reliable approaches are: use the BCL's System.Environment for common runtime values, and use WMI (System.Management) when you need detailed hardware or OS properties. Also, the VB "My" objects are wrappers that expose objects and properties rather than a single printable string, so inspect individual properties (or format them) rather than passing a whole object to a UI method.

A compact VB helper that gathers basic info and formats sizes:

Imports System.Text

Function GetBasicSystemInfo() As String
    Dim sb As New StringBuilder()
    sb.AppendLine("Machine: " & Environment.MachineName)
    sb.AppendLine("OS: " & Environment.OSVersion.ToString())
    sb.AppendLine("CLR: " & Environment.Version.ToString())
    sb.AppendLine("Processors: " & Environment.ProcessorCount.ToString())
    sb.AppendLine("64-bit OS: " & Environment.Is64BitOperatingSystem.ToString())
    Return sb.ToString()
End Function

Function HumanReadableBytes(bytes As ULong) As String
    Dim units As String() = {"B","KB","MB","GB","TB"}
    Dim size As Double = bytes
    Dim i As Integer = 0
    While size >= 1024 AndAlso i < units.Length - 1
        size /= 1024
        i += 1
    End While
    Return String.Format("{0:0.##} {1}", size, units(i))
End Function

When you need CPU model, BIOS, video adapter, or other hardware details, query WMI (add a reference to System.Management). Use the debugger Watch/Immediate windows to explore object properties while running. For API details see the System.Environment class and the ManagementObjectSearcher class.

Recommended Answers

All 3 Replies

If you have the 2005 or 2008 vs or express then use:

My.Computer.whatever_you_are_looking_for

I am unable to see it like this
My.Computer.Name
I have to put it in messagebox
also i canot see MessageBox.Show(My.Computer.Info) it gives error
Value of type'Microsoft.VisualBasic.Devices.ComputerInfo' cannot be converted to 'string'

Try this:

MessageBox.Show(My.Computer.Name.ToString)
        MessageBox.Show(My.Computer.Screen.WorkingArea.ToString)
        MessageBox.Show(My.Computer.Info.OSFullName.ToString)
        MessageBox.Show(My.Computer.Info.AvailablePhysicalMemory.ToString(Format("###,###,###")))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.