Skip to content

A C# library to query windows WMI information and return it encased in dictionaries

Notifications You must be signed in to change notification settings

slurrps-mcgee/WMI-Window-Query

Repository files navigation

WMI-Window-Query

A C# library to query windows WMI Win32 Provider information and return it encased in dictionaries. Please refer to microsofts documentation for win32 providers https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-provider. Right now it only queries drive information on a system but I will be adding all of the Win32 Provider information over time. There is an example project with how to use the library inside the solution. Please reference that for how to use the library. I mostly made this for a project I was working on but found using dictionaries to hold this information to be super easy to query and useful to use.

Usage

  1. Use GetDrives method to get all the drive letters attached to the computer
  2. Create a new Library for a specific drive or List<Win32_Library> if wanting to get all drives information
  3. Set the library to the return method GetSelectedDriveInformation(using the drive letter from the list of drives) or GetAllDrivesInformation to retrieve all drives information without selecting a specific drive
  4. Use the new filled dictionary of information from the query as needed

Please see the project WMI_TEST to see further examples of usage.

Queries

DriveQuery - Used to Query the Drives in the system it is being used on.

Custom Collections

Win32_Library - Holds a Dictionary of Win32_Book(s)

Win32_Book - Holds a Dictionary of Win32 Class Properties

DriveQuery Methods

Public Methods

  • List GetDrives
  • List GetPartitions(string driveLetter)
  • List<Win32_Library> GetAllDrivesInformation()
  • Win32_Library GetSelectedDriveInformation(string driveLetter)
  • float TotalSpace(Book dict)
  • float UsedSpace(Book dict) Helper Methods
  • bool ISOSDrive(string driveLetter)
  • string DriveType(string driveNumber)
  • float ConversionToGig(float conversionNum)
  • float ConversionToTer(float conversionNum)

Private Methods

  • Win32_Library GetLogicalInformation(string driveLetter)
  • Win32_Library GetDiskInformation(string driveLetter, out string diskNum)
  • Win32_Library GetPartitionInformation(string driveNum, string partitionNum)

ToDo

  • Add Helper Class for helper methods such as Conversion methods for byte sizes
  • Add ability to search specific Win32 providers besides disk queries such as system queries like CPU, Memory, Motherboard, etc this can be a abstract class and have each inherit this as win32 providers share some details. This will be implemented by creating a method that excepts a Win32_Provider enum value to get a Win32_book containing all properties of the specified Provider
  • Add Static Enum for different Win32 Providers called Win32_Providers for ability to search any provider not just disk related information.
  • Will also provide a list of said providers in documentation.

About

A C# library to query windows WMI information and return it encased in dictionaries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages