Home ProgrammingC# Visual C#: CPU monitoring gadget

Visual C#: CPU monitoring gadget

by Kliment Andreev
4.3K views

Windows 7 came with gadgets, small tools that sit on your desktop and do something. I used CPU/Memory gadget and the Weather gadget. Windows 8 and Windows 10, discontinued the gadgets, but there are some ways of how to install them back under Win 10.

I made a small tool in Visual C# (Community edition 2015) that does pretty much the same. It monitors the CPU usage and draws a graph. You can choose the background, transparency, threshold colors, etc… See the options screenshot below.

You can get the source here.

git clone https://www.github.com/klimenta/CPU-Gadget

If you get an exception while trying to compile or execute the program, it means your counters in registry are messed up.
This is the error that you might get.

InvalidOperationException: Cannot load Counter Name data because an invalid index '' was read from the registry.

Open the command prompt (Run as Administrator) and execute these commands depending on your OS (32/64) bit.

C:\windows\system32> lodctr /r

or

C:\windows\SysWOW64> lodctr /r

You should get this back if everything is OK.

Info: Successfully rebuilt performance counter setting from system backup store

If you get this, you are doing it for 32 bit OS instead of 64 bit OS and vice versa.

Error: Unable to rebuild performance counter setting from system backup store, error code is 2

This is how the gadget looks like on the desktop (click for larger image).

UPDATE 4/12/2016
================

Based on this source, I made slight modifications for another gadget that monitors the available RAM usage.
You can get the code here.

git clone https://www.github.com/klimenta/CPU-Gadget

Or get both executables from here (CPU Gadget) and here (RAM Gadget).

Related Articles

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More