Home /

| RSS

Get Windows Registry Size With WMI And C#

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.

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

Get Processor Information In .NET Using C#

.NET Framework provides classes which give information about the machine on which code is executed. One Such class is System.Environment which gives us things like Machine Name, OS Version and much more. I recently had a requirement to programmatically detect the number of Processors on a machine. I thought this was a simple enough task. [...]

[ More ] March 9th, 2009 | 1 Comment | Posted in Programming |

Get CD Or DVD Drive Information Using WMI And C#

This snippet shows you how to get information about all CD / DVD drives on your machine using WMI and C#. To run the code you need to add reference to System.Management.
ManagementObjectSearcher mgmtObjects =
new ManagementObjectSearcher("Select * from Win32_CDROMDrive");

foreach (var item in mgmtObjects.Get())
{
Console.WriteLine("Drive Letter – \t" + item["Drive"]);
Console.WriteLine("Name – [...]

[ More ] March 9th, 2009 | 1 Comment | Posted in Code Snippets |