Get System Specs (memory, processor etc...) in C#?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mateusz Rajca

    #1

    Get System Specs (memory, processor etc...) in C#?

    Hello,

    I would like to know how to find the specs of the current running system
    such as the memory amount and processor speed in C#?

    Mateusz

  • Michael Nemtsev

    #2
    Re: Get System Specs (memory, processor etc...) in C#?

    Hello Mateusz,

    use WMI for this. (call wmic.exe and type "cpu", "memlogical " for example
    to see info)
    To get info abt physical memmory use samble below. For CPU use "SELECT *
    FROM Win32_Processor "

    static void Main(string[] args)
    {
    double totalCapacity = 0;
    ObjectQuery objectQuery = new ObjectQuery("se lect * from
    Win32_PhysicalM emory");
    ManagementObjec tSearcher searcher = new
    ManagementObjec tSearcher(objec tQuery);
    ManagementObjec tCollection vals = searcher.Get();
    foreach(Managem entObject val in vals)
    {
    totalCapacity += System.Convert. ToDouble(val.Ge tPropertyValue( "Capacity") );
    }

    Console.WriteLi ne("Total Machine Memory = " + totalCapacity.T oString() + "
    Bytes");
    Console.WriteLi ne("Total Machine Memory = " + (totalCapacity / 1024) + "
    KiloBytes");
    Console.WriteLi ne("Total Machine Memory = " + (totalCapacity / 1048576) + "
    MegaBytes");
    Console.WriteLi ne("Total Machine Memory = " + (totalCapacity / 1073741824 )
    + " GigaBytes");
    Console.ReadLin e();

    }


    MR> Hello,
    MR>
    MR> I would like to know how to find the specs of the current running
    MR> system such as the memory amount and processor speed in C#?
    MR>
    MR> Mateusz
    MR>
    ---
    WBR,
    Michael Nemtsev :: blog: http://spaces.msn.com/laflour

    "At times one remains faithful to a cause only because its opponents do not
    cease to be insipid." (c) Friedrich Nietzsche


    Comment

    Working...