K kurotsuke Jun 16, 2005 #1 How can I retrieve the amount of RAM installed on the system and if the user has the Administrator privileges? Thanks a lot.
How can I retrieve the amount of RAM installed on the system and if the user has the Administrator privileges? Thanks a lot.
Y Yunus Emre ALPÖZEN [MCSD.NET] Jun 16, 2005 #2 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();
K kurotsuke Jun 16, 2005 #3 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(); Click to expand... 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(); Click to expand... I'm getting an exception on the WriteLine. Any idea on how to fix that? Thanks.
K kurotsuke Jun 16, 2005 #4 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(); Click to expand... I got the message telling me that the category doesn't exist. It looks like the problem is with both Memory and Available MBytes
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(); Click to expand... I got the message telling me that the category doesn't exist. It looks like the problem is with both Memory and Available MBytes
J Jon Skeet [C# MVP] Jun 16, 2005 #5 kurotsuke said: I'm getting an exception on the WriteLine. Any idea on how to fix that? Click to expand... It would help if you'd say exactly what the exception is. Could you post a short but complete program which demonstrates the problem? See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that.
kurotsuke said: I'm getting an exception on the WriteLine. Any idea on how to fix that? Click to expand... It would help if you'd say exactly what the exception is. Could you post a short but complete program which demonstrates the problem? See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that.