Nefarius.Utilities.DeviceManagement 3.11.295-pre

Prefix Reserved
This is a prerelease version of Nefarius.Utilities.DeviceManagement.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nefarius.Utilities.DeviceManagement --version 3.11.295-pre                
NuGet\Install-Package Nefarius.Utilities.DeviceManagement -Version 3.11.295-pre                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nefarius.Utilities.DeviceManagement" Version="3.11.295-pre" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nefarius.Utilities.DeviceManagement --version 3.11.295-pre                
#r "nuget: Nefarius.Utilities.DeviceManagement, 3.11.295-pre"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nefarius.Utilities.DeviceManagement as a Cake Addin
#addin nuget:?package=Nefarius.Utilities.DeviceManagement&version=3.11.295-pre&prerelease

// Install Nefarius.Utilities.DeviceManagement as a Cake Tool
#tool nuget:?package=Nefarius.Utilities.DeviceManagement&version=3.11.295-pre&prerelease                

<img src="assets/NSS-128x128.png" align="right" />

Nefarius.Utilities.DeviceManagement

Build status Requirements Nuget Nuget

Managed wrappers around SetupAPI, Cfgmgr32, NewDev and DrvStore native APIs on Windows.

Features

  • Listen for device plugin and unplug events without depending on WinForms or WPF
  • Enumerate devices (present and absent)
  • Get and set various unified device properties
  • Convert various notations (Symlink to Instance ID etc.)
  • Enumerate and remove elements form the Driver Store

Documentation

Link to API docs.

Generating documentation

  • dotnet build -c:Release
  • dotnet tool install -g XMLDoc2Markdown
  • xmldoc2md .\bin\netstandard2.0\Nefarius.Utilities.DeviceManagement.dll .\docs\

Examples

Some usage examples of the core library features are presented below.

Enumerate all USB devices

The Devcon utility class offers helper methods to find devices.

var instance = 0;
// enumerate all devices that export the GUID_DEVINTERFACE_USB_DEVICE interface
while (Devcon.FindByInterfaceGuid(DeviceInterfaceIds.UsbDevice, out var path,
           out var instanceId, instance++))
{
    Console.WriteLine($"Path: {path}, InstanceId: {instanceId}");

    var usbDevice = PnPDevice
        .GetDeviceByInterfaceId(path)
        .ToUsbPnPDevice();

    Console.WriteLine($"Got USB device {usbDevice.InstanceId}");
}

Listen for new and removed USB devices

One or more instances of the DeviceNotificationListener can be used to listen for plugin and unplug events of various devices. This class has no dependency on WinForms or WPF and works in Console Applications and Windows Services alike.

var listener = new DeviceNotificationListener();

listener.DeviceArrived += Console.WriteLine;
listener.DeviceRemoved += Console.WriteLine;

// start listening for plugins or unplugs of GUID_DEVINTERFACE_USB_DEVICE interface devices
listener.StartListen(DeviceInterfaceIds.UsbDevice);

Get all driver packages in the Driver Store

var allDriverPackages = DriverStore.ExistingDrivers.ToList();

Remove all copies of mydriver.inf from the Driver Store

foreach (var driverPackage in allDriverPackages.Where(p => p.Contains("mydriver.inf", StringComparison.OrdinalIgnoreCase)))
{
    DriverStore.RemoveDriver(driverPackage);
}
// e.g. the path "\\?\HID#VID_045E&PID_028E&IG_00#3&31f0e99d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
// gets translated to instanceId "HID\VID_045E&PID_028E&IG_00\3&31f0e99d&0&0000"
var instanceId = PnPDevice.GetInstanceIdFromInterfaceId(path);
// example path: "\\?\HID#VID_046D&PID_C33F&MI_01&COL02#B&31580538&0&0001#{4D1E55B2-F16F-11CF-88CB-001111000030}"
PnPDevice device = PnPDevice.GetDeviceByInterfaceId(path);

Sources & 3rd party credits

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Nefarius.Utilities.DeviceManagement:

Package Downloads
Nefarius.Drivers.HidHide

Managed API for configuring HidHide.

Wujek_Dualsense_API

Wujek Dualsense API is a .NET library designed to interface with the PlayStation DualSense controller, providing functionalities to control its various features such as haptic feedback, LEDs, triggers, and more.

Nefarius.Utilities.Bluetooth

Utility library for unconventional Bluetooth tasks on Windows.

O.Usb

Package Description

OakreyHardwareManager.Plugin.Helpers

Oakrey Hardware Manager Plugin Helpres

GitHub repositories (6)

Showing the top 5 popular GitHub repositories that depend on Nefarius.Utilities.DeviceManagement:

Repository Stars
Valkirie/HandheldCompanion
ControllerService
CircumSpector/DS4Windows
A reimagination of DS4Windows.
project-sbc/Handheld-Control-Panel
nefarius/Legacinator
The one and only Legacinator
InvoxiPlayGames/FestivalInstrumentMapper
Maps most existing Rock Band / Guitar Hero instruments as Xbox One instruments for Fortnite Festival.
Version Downloads Last updated
5.1.0 328 a month ago
5.0.0 1,813 5 months ago
5.0.0-pre001 85 5 months ago
4.0.3 142 5 months ago
4.0.3-pre001 80 5 months ago
4.0.2 237 5 months ago
4.0.1 701 6 months ago
4.0.0 1,438 6 months ago
4.0.0-pre002 80 6 months ago
4.0.0-pre001 86 6 months ago
3.23.0 578 7 months ago
3.22.0 1,964 9 months ago
3.21.0 142 9 months ago
3.20.0 127 9 months ago
3.19.0 278 9 months ago
3.19.0-pre3 118 9 months ago
3.19.0-pre2 104 9 months ago
3.18.1 1,530 3/11/2024
3.17.406 2,485 8/29/2023
3.17.403 302 8/27/2023
3.17.401-pre 142 8/26/2023
3.16.384-pre 178 8/23/2023
3.14.305 2,412 5/14/2023
3.13.303-pre 160 5/14/2023
3.12.297-pre 224 5/13/2023
3.11.295-pre 187 5/12/2023
3.10.293-pre 235 5/9/2023
3.9.255 1,724 4/9/2023
3.8.228 1,237 2/2/2023
3.8.225-pre 198 2/1/2023
3.6.213 742 1/12/2023
3.6.211 335 1/12/2023
3.5.209 545 12/26/2022
3.4.206 416 12/20/2022
3.4.204-pre 180 12/19/2022
3.4.202-pre 169 12/19/2022
3.3.196 708 10/16/2022
3.2.193 429 10/16/2022
3.2.191 427 10/16/2022
3.2.189 446 10/16/2022
3.2.186 436 10/16/2022
3.2.184 709 9/29/2022
3.2.175 528 9/12/2022
3.1.173 428 9/12/2022
3.1.171 440 9/12/2022
3.0.168 462 9/10/2022
3.0.165-pre 258 9/9/2022
2.9.116 508 8/25/2022
2.8.110 1,162 7/19/2022
2.8.107 744 6/15/2022
2.7.104 472 6/14/2022
2.6.102 625 6/2/2022
2.6.100 499 5/26/2022
2.6.98 521 5/24/2022
2.4.94 525 5/19/2022
2.4.91 508 5/14/2022
2.4.89 445 5/14/2022
2.3.87 472 5/13/2022
2.2.85 498 5/11/2022
2.1.76 465 5/11/2022
2.1.74 475 5/10/2022
2.0.71 491 5/10/2022
2.0.68 509 5/8/2022
2.0.66 472 5/8/2022
2.0.60 477 5/8/2022
1.6.50 509 5/6/2022
1.6.48-beta 210 5/6/2022
1.4.42-beta 1,010 2/1/2022
1.3.28-beta 231 1/30/2022
1.2.24-beta 215 1/30/2022
1.2.22-beta 211 1/30/2022
1.1.20-beta 219 1/30/2022
1.0.18-beta 223 1/30/2022
1.0.15-beta 376 1/17/2022
1.0.13-beta 218 1/17/2022
1.0.11-beta 217 1/17/2022
1.0.6-beta 224 1/16/2022
1.0.4-beta 228 1/16/2022
1.0.2-beta 230 1/16/2022