1

I have Windows XP which do not provide the Categories Processor or Memory, and I cannot bring it to show them (I'm not allowed to edit the registry nor to change System Files)

Is there any way to get the actual CPU usage and Free Memory without using PerformanceCounter?

I'm using .NET 3.5 and C# on Windows XP SP2

Marlon
  • 19,924
  • 12
  • 70
  • 101
Christian Elsner
  • 113
  • 1
  • 4
  • 15

3 Answers3

2

To get the Processor usage without performance counter using WMI, Look at win32_Processor class. and if you want to see the total memory available use GC.GetTotalMemory - Process.GetCurrentProcess().PrivateMemorySize64;

Rajesh Subramanian
  • 6,400
  • 5
  • 29
  • 42
  • your code returns -26 MB of Free Mem, I also don't get why you substract the current process. I understand that GC.GetTotalMemory returns the number of reserved bytes. Does your code only return the memory available to .NET? can you explain what you are doing? – Christian Elsner Jun 18 '12 at 12:42
  • see the following link to get the total memory and http://stackoverflow.com/questions/105031/c-sharp-how-do-you-get-total-amount-of-ram-the-computer-has – Rajesh Subramanian Jun 18 '12 at 14:08
1

Would you be able to use native win32 API calls? If so then they would provide the information your after.

See the following article: CodeProject: Calling API functions using C#

cjb110
  • 1,310
  • 14
  • 30
0

If you are using .net 4 and you are only interested in what your current app domain is doing then you can use this:

this.AppDomain.MonitoringTotalProcessorTime

See MSDN Documentation MonitoringTotalProcessorTime

Daniel James Bryars
  • 4,429
  • 3
  • 39
  • 57