Code Monkey home page Code Monkey logo

wmigatherer's Introduction

WMIGatherer - A WMI wrapper and system information gatherer

WMIGatherer provides simple and easy WMI querying and already contains functionality to gather useful system informations.

Usage

Query Creation

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 is null
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");

What to do with WmiClassCollection

  • WmiClassCollection is an ICollection of all queried classes (WmiClass)
  • Each WmiClass carries its properties (WmiProperty)
  • Each WmiProperty contains Name and Value
  • A WmiProperty inside a WmiClass can be accessed by either:
    • iterating through WmiClass.Properties
    • using the Name property of WmiProperty as index (WmiClass["Name Of Property"])
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

Built-In System Information Gathering

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, ...)

Examples

Get antivirus, antispyware and firewall product:

  • SecurityProductType.AntiVirus gets antivirus software
  • SecurityProductType.AntiSpyware gets antispyware software
  • SecurityProductType.Firewall gets 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.Light uses CPU ID
  • HwidStrength.Medium uses CPU ID + HDD Signature
  • HwidStrength.Medium uses 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...
}

Requirements

  • .NET Framwork 3.5 or higher

wmigatherer's People

Contributors

chrizator avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.