For today's example, we will retrieve the windows registry size.
First we must include the following namespaces on our Using directives.
Using System.Management;
Now to retrieve the size of the current machine's registry size, cut and paste the following code.
ManagementObjectSearcher mgmtObjects =
new ManagementObjectSearcher("Select * from Win32_Registry");
foreach (var mosItem in mgmtObjects.Get())
{
Console.WriteLine(string.Format("Current Size: {0}MB", mosItem["CurrentSize"]));
Console.WriteLine(string.Format("Maximum Size: {0}MB", mosItem["MaximumSize"]));
}
For more coding tips & tricks, subscribe now.
0 comments:
Post a Comment