locked
Installed Physical Memory

    Question

  • What method is Windows 7 using to report the Installed Physical Memory of a given machine and is this value also accessible with the .Net Framework without using an API call.  I know that Total/Availible Physical Memory as well as Virtual Memory values are availible.  Just wondering if the Total Installed value is also in there somewhere.

    Also wondering if System Name, Manufactuer, Model, Type, Processor, BIOS Version, Local, Tine Zone, HAL values are available without having to make API calls?

    Tuesday, March 20, 2012 7:43 AM

Answers

  • Hi V.Shane,

    I’m not sure if this could be done without using API. However, it would be an easier way if use API.  You can generate code by WMI genaretor.  The following example codes was generated, to use them you need to add reference to System.management:

    Imports System.Net
    Imports System.Management
    Public Class Form1
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            ' get the full name of a computer
            Dim domainName As String = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName
            Dim hostName As String = Dns.GetHostName()
            Dim fqdn As String = ""
            If (hostName.Contains(domainName) = False) Then
                fqdn = hostName + "." + domainName
            Else
                fqdn = hostName
            End If
            Console.WriteLine(fqdn)
            'get the model of system by searching the Win32_ComputerSystem
            Dim query As String = "SELECT * FROM Win32_ComputerSystem"
            Dim searcher As New ManagementObjectSearcher(query)
            For Each info As ManagementObject In searcher.Get()
                Console.WriteLine(info.Properties("Manufacturer").Value.ToString & info.Properties("Model").Value.ToString)
            Next info
            ' get the processor name
            Dim processer As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_Processor")
            For Each prs As ManagementObject In processer.[Get]()
                Console.WriteLine(prs("Name"))
            Next
            'use the computerInfo to get the memory
            Dim inf As New Microsoft.VisualBasic.Devices.ComputerInfo()
            Console.WriteLine(inf.TotalPhysicalMemory)
            'check if the OS is 64bit
            Console.WriteLine(Environment.Is64BitOperatingSystem)
        End Sub
    End Class

    This reference link may be helpful also: http://social.msdn.microsoft.com/Forums/is/vbgeneral/thread/f2f52fea-eccd-4582-b3cd-b6a43fc6c5d0

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us


    Wednesday, March 21, 2012 7:48 AM
    Moderator