WMIGatherer provides simple and easy WMI querying and already contains functionality to gather useful system informations.
If only one property of one WMI class is required:
string windowsCaption = Wmi.PropertyQuery<string>("Win32_OperatingSystem", "Caption");- When querying a property as a primitive type (
int,long,DateTime) always use nullables (int?,long?,DateTime?) in order to check if the property isnull
ulong? capacity = Wmi.PropertyQuery<ulong?>("Win32_PhysicalMemory", "Capacity");If multiple properties or multiple WMI classes are required:
string[] properties = new string[] { "Capacity", "PositionInRow" };
string condition = "PositionInRow = 1";
WmiClassCollection classCollection = Wmi.Query("Win32_PhysicalMemory", properties, condition);If a custom query string (WQL syntax) needs to be used:
WmiClassCollection classCollection = Wmi.CustomQuery("SELECT Name, Caption FROM Win32_Bios");WmiClassCollectionis anICollectionof all queried classes (WmiClass)- Each
WmiClasscarries its properties (WmiProperty) - Each
WmiPropertycontainsNameandValue - A
WmiPropertyinside aWmiClasscan be accessed by either:- iterating through
WmiClass.Properties - using the
Nameproperty ofWmiPropertyas index (WmiClass["Name Of Property"])
- iterating through
foreach (WmiClass wmiClass in classCollection)
{
uint? posInRow = wmiClass["PositionInRow"];
ulong? capacity = wmiClass["Capacity"];
// Do something with it...
}- If the property type is primitive, it's always a nullable since a WMI property can be null
Besides the easy to use querying system, WMIGatherer offers an information gathering functionality using preset WMI queries.
- Hardware (CPU, GPU, HDD, RAM, Mainboard, HWID Creation, ...)
- Operating System (Serial Number, Caption, Architecture, ...)
- Security (Antivirus, Antispyware, Firewall)
- User (Name, FullName)
- Network (Network Adapter, MAC-Addresses, ...)
Get antivirus, antispyware and firewall product:
SecurityProductType.AntiVirusgets antivirus softwareSecurityProductType.AntiSpywaregets antispyware softwareSecurityProductType.Firewallgets firewall applications
using WMIGatherer.Gathering;
using WMIGatherer.Enums;
// var = ICollection<SecurityProduct>
var antiviruses = SecurityGatherer.GetSecurityProducts(SecurityProductType.AntiVirus);
foreach (var av in antiviruses)
{
string name = av.Name;
string path = av.PathToExe;
// Do something with it...
}Create custom HWID:
HwidStrength.Lightuses CPU IDHwidStrength.Mediumuses CPU ID + HDD SignatureHwidStrength.Mediumuses CPU ID + HDD Signature + BIOS Serial Number + MAC Address
using WMIGatherer.Gathering;
using WMIGatherer.Enums;
string hwid = HardwareGatherer.GetHwid(HwidStrength.Medium);
// Do something with it...Get MAC-Address of IP enabled network interfaces:
using WMIGatherer.Gathering;
string macAddress = NetGatherer.GetActiveMacAddress();Retrieve all RAM sticks:
using WMIGatherer.Gathering;
// var = ICollection<RamStick>
var ramSticks = HardwareGatherer.GetRamSticks();
foreach (var stick in ramSticks)
{
ulong? capacity = stick.Capacity;
uint? clockSpeed = stick.ClockSpeed;
// ...
// Do something with it...
}- .NET Framwork 3.5 or higher