c# - System.Management, Management Object Searcher, and RAM -


i brand new coding , i'm having go @ trying make simple app shows computer information in multiline textbox, do.

so, managed basics searching registry os name, version, etc , using system.environment current logged in user, architecture, etc , used managementobjectsearcher name of cpu , total ram.

my problem have 4 memory sticks installed while app technically gives me ask returning total size of each memory stick, want 1 instance of 16gb instead of 4 instances of 4gb. used:

managementobjectsearcher search = new managementobjectsearcher("select * win32_physicalmemory");  foreach (managementobject ram in search.get())             {                 txtsysteminfo.text += "\r\nram: " + convert.todouble(ram.getpropertyvalue("capacity")) / 1073741824 + "gb";         } 

output looks this:

username: xxxx os: windows x.x (arch) version: x.x build xxxx cpu: intel blah blah ram: 4gb ram: 4gb ram: 4gb ram: 4gb 

obviously i've jumped in deep end why can't 1 click appreciated.

simply increment total in loop, format , display;

uint64 total = 0; foreach (managementobject ram in search.get()) {     total += (uint64)ram.getpropertyvalue("capacity"); }  txtsysteminfo.text += "\r\nram: " + total / 1073741824 + "gb"; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -