Retrieving system information

  • Thread starter Thread starter kurotsuke
  • Start date Start date
K

kurotsuke

How can I retrieve the amount of RAM installed on the system and if
the user has the Administrator privileges?

Thanks a lot.
 
Use performance counters...

Sample code;

System.Diagnostics.PerformanceCounter pCounter = new
System.Diagnostics.PerformanceCounter();

pCounter.CounterName = "System Code Total Bytes";

pCounter.CategoryName = "Memory";

Console.WriteLine( pCounter.RawValue.ToString() );

pCounter.CounterName = "Available MBytes";

Console.WriteLine(pCounter.RawValue.ToString());

Console.Read();
 
Use performance counters...

Sample code;

System.Diagnostics.PerformanceCounter pCounter = new
System.Diagnostics.PerformanceCounter();

pCounter.CounterName = "System Code Total Bytes";

pCounter.CategoryName = "Memory";

Console.WriteLine( pCounter.RawValue.ToString() );

pCounter.CounterName = "Available MBytes";

Console.WriteLine(pCounter.RawValue.ToString());

Console.Read();

I'm getting an exception on the WriteLine. Any idea on how to fix
that?
Thanks.
 
Use performance counters...

Sample code;

System.Diagnostics.PerformanceCounter pCounter = new
System.Diagnostics.PerformanceCounter();

pCounter.CounterName = "System Code Total Bytes";

pCounter.CategoryName = "Memory";

Console.WriteLine( pCounter.RawValue.ToString() );

pCounter.CounterName = "Available MBytes";

Console.WriteLine(pCounter.RawValue.ToString());

Console.Read();

I got the message telling me that the category doesn't exist. It looks
like the problem is with both Memory and Available MBytes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top