![]() |
VOOZH | about |
dotnet add package Nefarius.Utilities.DeviceManagement --version 5.2.0
NuGet\Install-Package Nefarius.Utilities.DeviceManagement -Version 5.2.0
<PackageReference Include="Nefarius.Utilities.DeviceManagement" Version="5.2.0" />
<PackageVersion Include="Nefarius.Utilities.DeviceManagement" Version="5.2.0" />Directory.Packages.props
<PackageReference Include="Nefarius.Utilities.DeviceManagement" />Project file
paket add Nefarius.Utilities.DeviceManagement --version 5.2.0
#r "nuget: Nefarius.Utilities.DeviceManagement, 5.2.0"
#:package Nefarius.Utilities.DeviceManagement@5.2.0
#addin nuget:?package=Nefarius.Utilities.DeviceManagement&version=5.2.0Install as a Cake Addin
#tool nuget:?package=Nefarius.Utilities.DeviceManagement&version=5.2.0Install as a Cake Tool
👁 .NET
👁 Requirements
👁 Nuget
👁 Nuget
Managed wrappers around SetupAPI, Cfgmgr32, NewDev and DrvStore Windows APIs.
.
Some usage examples of the core library features are presented below.
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}");
}
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);
var allDriverPackages = DriverStore.ExistingDrivers.ToList();
mydriver.inf from the Driver Storeforeach (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);
string service = "HidHide";
DeviceClassFilters.AddUpper(DeviceClassIds.XnaComposite, service);
const string instanceId = @"USB\VID_054C&PID_0CE6&MI_03\9&DC32669&3&0003";
PnPDevice device = PnPDevice.GetDeviceByInstanceId(instanceId);
// required for the next call to succeed
device.InstallNullDriver();
Thread.Sleep(1000);
// accepts any INF already present in C:\Windows\INF directory
device.InstallCustomDriver("winusb.inf");
const string instanceId = @"USB\VID_054C&PID_0CE6&MI_03\9&DC32669&3&0003";
PnPDevice device = PnPDevice.GetDeviceByInstanceId(instanceId);
// uninstall/deconfigure device
device.Uninstall();
Thread.Sleep(1000);
// trigger re-enumeration
Devcon.Refresh();
if (Devcon.FindByInterfaceGuid(HostRadio.DeviceInterface, out PnPDevice radioDevice))
{
UsbPnPDevice? usbHostRadio = radioDevice.ToUsbPnPDevice();
usbHostRadio.CyclePort();
}
This library benefits from these awesome projects ❤ (appearance in no special order):
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
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 |
|
|
Oakrey.Applications.UsbNotifying
Windows-only .NET service that wraps the Windows PnP device notification API and exposes USB device arrival and removal events as an IObservable<UsbEventArgs> stream, backed by a ReplaySubject from System.Reactive. |
Showing the top 7 popular GitHub repositories that depend on Nefarius.Utilities.DeviceManagement:
| Repository | Stars |
|---|---|
|
Valkirie/HandheldCompanion
ControllerService
|
|
|
CircumSpector/DS4Windows
A reimagination of DS4Windows.
|
|
|
nefarius/Legacinator
The one and only Legacinator.
|
|
| project-sbc/Handheld-Control-Panel | |
|
InvoxiPlayGames/FestivalInstrumentMapper
Maps most existing Rock Band / Guitar Hero instruments as Xbox One instruments for Fortnite Festival.
|
|
|
Struggleton/Delfinovin
An XInput solution for Gamecube Controllers
|
|
|
project-sbc/Handheld-Hardware-Tools
Software that compliments Windows laptops/tablets/gaming handhelds to allow easy control of TDP, brightness, cpu clock, etc.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 5.2.0 | 2,814 | 10/14/2025 |
| 5.2.0-pre003 | 209 | 10/14/2025 |
| 5.2.0-pre002 | 217 | 10/14/2025 |
| 5.2.0-pre001 | 231 | 10/14/2025 |
| 5.1.0 | 5,028 | 2/23/2025 |
| 5.0.0 | 5,429 | 11/9/2024 |
| 5.0.0-pre001 | 199 | 11/9/2024 |
| 4.0.3 | 311 | 11/7/2024 |
| 4.0.3-pre001 | 183 | 11/7/2024 |
| 4.0.2 | 458 | 10/30/2024 |
| 4.0.1 | 1,068 | 10/1/2024 |
| 4.0.0 | 1,876 | 9/20/2024 |
| 4.0.0-pre002 | 183 | 9/20/2024 |
| 4.0.0-pre001 | 201 | 9/20/2024 |
| 3.23.0 | 870 | 8/17/2024 |
| 3.22.0 | 7,571 | 7/7/2024 |
| 3.21.0 | 307 | 7/4/2024 |
| 3.20.0 | 276 | 7/4/2024 |
| 3.19.0 | 465 | 6/30/2024 |
| 3.19.0-pre3 | 232 | 6/28/2024 |