Home / Code Snippets / Blog article: Get Windows Registry Size With WMI And C#

| RSS

Get Windows Registry Size With WMI And C#

March 29th, 2009 | No Comments | Posted in Code Snippets

Windows Registry Size can be retrieved using WMI objects. This code snippet shows you how to get current size and maximum size for Windows registry.

ManagementObjectSearcher mgmtObjects = 
  new ManagementObjectSearcher("Select * from Win32_Registry");

foreach (var item in mgmtObjects.Get())
{
  Console.WriteLine(string.Format("Current Size: {0}MB", item["CurrentSize"]));
  Console.WriteLine(string.Format("Maximum Size: {0}MB", item["MaximumSize"]));
}

 

The output.

Windows Registry Size

Leave a Reply 2871 views, 3 so far today |

Leave a Reply