Hardware.Info
10.1.0.1
See the version list below for details.
dotnet add package Hardware.Info --version 10.1.0.1
NuGet\Install-Package Hardware.Info -Version 10.1.0.1
<PackageReference Include="Hardware.Info" Version="10.1.0.1" />
<PackageVersion Include="Hardware.Info" Version="10.1.0.1" />
<PackageReference Include="Hardware.Info" />
paket add Hardware.Info --version 10.1.0.1
#r "nuget: Hardware.Info, 10.1.0.1"
#:package Hardware.Info@10.1.0.1
#addin nuget:?package=Hardware.Info&version=10.1.0.1
#tool nuget:?package=Hardware.Info&version=10.1.0.1
Hardware.Info
Battery, BIOS, CPU - processor, storage drive, keyboard, RAM - memory, monitor, motherboard, mouse, NIC - network adapter, printer, sound card - audio card, graphics card - video card. Hardware.Info is a .NET Standard 2.0 library and uses WMI on Windows, /dev, /proc, /sys on Linux and sysctl, system_profiler on macOS.
How to use:
Include NuGet package from https://www.nuget.org/packages/Hardware.Info
<ItemGroup> <PackageReference Include="Hardware.Info" Version="10.1.0.1" /> </ItemGroup>Call
RefreshAll()or one of the otherRefresh*()methods:class Program { static readonly IHardwareInfo hardwareInfo = new HardwareInfo(); static void Main(string[] _) { //hardwareInfo.RefreshOperatingSystem(); //hardwareInfo.RefreshMemoryStatus(); //hardwareInfo.RefreshBatteryList(); //hardwareInfo.RefreshBIOSList(); //hardwareInfo.RefreshCPUList(); //hardwareInfo.RefreshDriveList(); //hardwareInfo.RefreshKeyboardList(); //hardwareInfo.RefreshMemoryList(); //hardwareInfo.RefreshMonitorList(); //hardwareInfo.RefreshMotherboardList(); //hardwareInfo.RefreshMouseList(); //hardwareInfo.RefreshNetworkAdapterList(); //hardwareInfo.RefreshPrinterList(); //hardwareInfo.RefreshSoundDeviceList(); //hardwareInfo.RefreshVideoControllerList(); hardwareInfo.RefreshAll(); Console.WriteLine(hardwareInfo.OperatingSystem); Console.WriteLine(hardwareInfo.MemoryStatus); foreach (var hardware in hardwareInfo.BatteryList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.BiosList) Console.WriteLine(hardware); foreach (var cpu in hardwareInfo.CpuList) { Console.WriteLine(cpu); foreach (var cpuCore in cpu.CpuCoreList) Console.WriteLine(cpuCore); } Console.ReadLine(); foreach (var drive in hardwareInfo.DriveList) { Console.WriteLine(drive); foreach (var partition in drive.PartitionList) { Console.WriteLine(partition); foreach (var volume in partition.VolumeList) Console.WriteLine(volume); } } Console.ReadLine(); foreach (var hardware in hardwareInfo.KeyboardList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.MemoryList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.MonitorList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.MotherboardList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.MouseList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.NetworkAdapterList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.PrinterList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.SoundDeviceList) Console.WriteLine(hardware); foreach (var hardware in hardwareInfo.VideoControllerList) Console.WriteLine(hardware); Console.ReadLine(); foreach (var address in HardwareInfo.GetLocalIPv4Addresses(NetworkInterfaceType.Ethernet, OperationalStatus.Up)) Console.WriteLine(address); Console.WriteLine(); foreach (var address in HardwareInfo.GetLocalIPv4Addresses(NetworkInterfaceType.Wireless80211)) Console.WriteLine(address); Console.WriteLine(); foreach (var address in HardwareInfo.GetLocalIPv4Addresses(OperationalStatus.Up)) Console.WriteLine(address); Console.WriteLine(); foreach (var address in HardwareInfo.GetLocalIPv4Addresses()) Console.WriteLine(address); Console.ReadLine(); } }
Known issues
21 second delay on first use in Windows
Hardware.Info uses WMI (Windows Management Instrumentation) on Windows OS. For certain queries WMI takes 21 seconds to initialize the first time you use it, after that all subsequent queries will execute immediately. If WMI isn't used for 15 minutes it will have to be initialized again the next time you use it.
The 21 second initialization delay is caused by RPC that WMI uses internally. In RPC documentation it says that the RPC/TCP time-out interval is defined with a SCMApiConnectionParam registry value located at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control and that the default value is set to 21,000 (21 seconds).
You can avoid the 21 second delay by excluding the queries that cause it (see Settings).
Settings
Constructor settings:
HardwareInfo(bool useAsteriskInWMI = true, TimeSpan? timeoutInWMI = null)
The construcotr accepts two settings for WMI:
useAsteriskInWMIcauses WMI queries to useSELECT * FROMinstead ofSELECTwith a list of property names. This is slower, but safer, more compatible with older Windows (XP, Vista, 7, 8) where a certain WMI property might be missing and throw an exception when queried by name. The default value istrue.timeoutInWMIsets theTimeoutproperty of theEnumerationOptionsin theManagementObjectSearcherthat executes the query. The default value isEnumerationOptions.InfiniteTimeout. Changing this could cause the query to return empty results in certain cases.
Refresh methods settings:
In these two methods you can exclude some slow queries by setting the parameters to false:
RefreshCPUList(bool includePercentProcessorTime = true)
RefreshNetworkAdapterList(bool includeBytesPersec = true, bool includeNetworkAdapterConfiguration = true)
Setting includePercentProcessorTime and includeBytesPersec to false will exclude the queries that:
- cause a 21 second delay the first time they are called in Windows
- cause a 1 second delay every time they are called in Linux
Setting includeNetworkAdapterConfiguration to false has only a small impact on performance.
Benchmarks
Windows 8.1 (Intel i5-2500, 8 GB RAM):
| Method | Mean | Error | StdDev |
|---|---|---|---|
| RefreshMemoryStatus | 947.8 ns | 3.77 ns | 3.53 ns |
| RefreshBatteryList | 1,811,885.7 ns | 12,921.05 ns | 11,454.17 ns |
| RefreshBIOSList | 2,086,001.0 ns | 23,896.69 ns | 22,352.98 ns |
| RefreshCPUList | 1,543,579,005.2 ns | 2,405,376.47 ns | 2,132,303.59 ns |
| RefreshDriveList | 409,137,516.3 ns | 8,612,410.99 ns | 25,258,710.57 ns |
| RefreshKeyboardList | 5,568,039.5 ns | 44,228.57 ns | 41,371.43 ns |
| RefreshMemoryList | 2,120,024.5 ns | 26,103.39 ns | 24,417.13 ns |
| RefreshMonitorList | 5,669,237.8 ns | 50,801.76 ns | 45,034.44 ns |
| RefreshMotherboardList | 1,965,222.9 ns | 14,387.30 ns | 13,457.89 ns |
| RefreshMouseList | 6,003,924.9 ns | 60,725.05 ns | 50,708.17 ns |
| RefreshNetworkAdapterList | 1,412,244,738.6 ns | 14,681,615.28 ns | 12,259,813.69 ns |
| RefreshPrinterList | 28,244,822.2 ns | 143,359.60 ns | 134,098.66 ns |
| RefreshSoundDeviceList | 3,608,577.5 ns | 68,688.62 ns | 73,496.06 ns |
| RefreshVideoControllerList | 11,568,549.2 ns | 54,666.07 ns | 48,460.05 ns |
Version history:
- 10.1.0.1:
- Fixed
CPU.NameandCPU.CurrentClockSpeedin macOS - by @davidaramant - Added
CPU.MaxClockSpeedin macOS - by @davidaramant
- Fixed
- 10.1.0.0:
- Fixed
PercentProcessorTimein Windows - thanks to @C6OI
- Fixed
- 10.0.1.1:
- Added
GetOperatingSystem()in Windows, macOS, Linux - thanks to @adhip94
- Added
- 10.0.1.0:
- Added
GetBatteryList()in macOS - by @Tadelsucht
- Added
- 10.0.0.1:
- Fixed
GetBatteryList()in Linux - by @Tadelsucht
- Fixed
- 10.0.0.0:
- Fixed
GetDriveList()andGetMemoryList()in Linux - thanks to @misaka00251
- Fixed
- 1.1.1.1:
- Added
Memory.BankLabel,Memory.MinVoltage,Memory.MaxVoltagein Windows - by @AathifMahir - Added
CPU.SocketDesignation,CPU.SecondLevelAddressTranslationExtensionsin Windows - by @AathifMahir - Added Windows version check for WMI properties that require at least Windows 8
- Added Windows version check for WMI properties that require at least Windows 10
- Added XML summary for public properties in every class.
- Added
- 1.1.1.0:
- Added
IHardwareInfoso thatHardwareInfocan be mocked - by @240026763
- Added
- 1.1.0.1:
- Added two settings for WMI queries in Windows
- Added three settings to exclude slow queries in Windows, macOS, Linux
- 1.1.0.0:
- Fixed reading
MemAvailableinstead ofMemFreein Linux - by @schotime
- Fixed reading
- 1.0.1.1:
- 1.0.1.0:
- 1.0.0.1:
- Added
Battery.EstimatedChargeRemainingin Windows, Linux - by @reptail
- Added
- 1.0.0.0:
- Added
Battery.ExpectedLifein Linux - Added
Battery.EstimatedRunTimein Linux - Added
Battery.MaxRechargeTimein Linux - Added
Battery.TimeToFullChargein Linux
- Added
- 0.1.1.1:
- Added
Battery.DesignCapacityin Linux - Added
Battery.FullChargeCapacityin Linux
- Added
- 0.1.1.0:
- Added
Battery.BatteryStatusDescriptionin Linux
- Added
- 0.1.0.1:
- Added
Monitorinfo in macOS - Added
VideoControllerinfo in macOS
- Added
- 0.1.0.0:
- Added
CPU.L2CacheSizein macOS - Added
CPU.L3CacheSizein macOS - Added
Memoryinfo in macOS
- Added
- 0.0.1.1:
- Added
BIOS.ReleaseDatein Linux - Added
CPU.Manufacturerin Linux - Added
CPU.L3CacheSizein Linux - Added
Motherboard.SerialNumberin Linux - Fixed
NetworkAdapterinfo in Linux - Fixed
GetLocalIPv4Addresses()in macOS
- Added
- 0.0.1.0:
- Added
GetLocalIPv4Addresses()in Windows, macOS, Linux - Added
Motherboard.SerialNumberin Windows - Added
Drive,NetworkAdapterinfo in macOS, Linux
- Added
- 0.0.0.1:
- All hardware info in Windows
- CPU, RAM info in macOS, Linux
| Product | Versions 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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. |
-
.NETStandard 2.0
- System.Management (>= 4.7.0)
NuGet packages (35)
Showing the top 5 NuGet packages that depend on Hardware.Info:
| Package | Downloads |
|---|---|
|
HexaEightJWTLibrary
Create and Validate HexaEight JWT Tokens using this Libarary. This Library provides helper functions to implement HexaEight authenticated encryption and decryption of messages. |
|
|
Dijing.Common.Core
Dijing.Common is a common library for .netcore |
|
|
PGCG.commonItems
Package Description |
|
|
Jakar.Database
Package Description |
|
|
Lobster.Boot
LobsterBoot核心类库 |
GitHub repositories (10)
Showing the top 10 popular GitHub repositories that depend on Hardware.Info:
| Repository | Stars |
|---|---|
|
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
|
|
|
PixiEditor/PixiEditor
PixiEditor is a Universal Editor for all your 2D needs
|
|
|
Stability-AI/StableSwarmUI
StableSwarmUI, A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
|
|
|
mcmonkeyprojects/SwarmUI
SwarmUI (formerly StableSwarmUI), A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
|
|
|
ErsatzTV/ErsatzTV
Open-source platform that transforms your personal media library into live, custom TV channels.
|
|
|
codeproject/CodeProject.AI-Server
CodeProject.AI Server is a self contained service that software developers can include in, and distribute with, their applications in order to augment their apps with the power of AI.
|
|
|
akash-network/awesome-akash
Awesome List of Akash Deployment Examples
|
|
|
AscensionGameDev/Intersect-Engine
Intersect provides a complete game development suite for creating 2d mmorpgs with no programming experience required!
|
|
|
HexaEngine/HexaEngine
The official repo of the HexaEngine game engine
|
|
|
oncemi/OnceMi.Framework
基于.NET 7和Vue 2开发的企业级前后端分离权限管理开发框架(后台管理系统),具有组织管理、角色管理、用户管理、菜单管理、授权管理、计划任务、文件管理等功能。支持国内外多种流行数据库,支持IdentityServer4认证中心。
|
| Version | Downloads | Last Updated |
|---|---|---|
| 101.1.0.1 | 7,981 | 11/5/2025 |
| 101.1.0 | 24,938 | 9/21/2025 |
| 101.0.1.1 | 124,084 | 5/28/2025 |
| 101.0.1 | 144,106 | 2/16/2025 |
| 101.0.0.1 | 32,122 | 2/6/2025 |
| 101.0.0 | 524,729 | 9/19/2024 |
| 100.1.1.1 | 2,995 | 9/18/2024 |
| 100.1.1 | 93,004 | 8/29/2024 |
| 100.1.0.1 | 106,100 | 7/5/2024 |
| 100.1.0 | 127,835 | 3/2/2024 |
| 100.0.1.1 | 61,271 | 1/5/2024 |
| 100.0.1 | 10,111 | 12/8/2023 |
| 100.0.0.1 | 25,141 | 11/30/2023 |
| 100.0.0 | 19,621 | 9/17/2023 |
| 11.1.1.1 | 28,600 | 7/19/2023 |
| 11.1.1 | 1,849 | 7/16/2023 |
| 11.1.0.1 | 36,576 | 7/7/2023 |
| 11.1.0 | 11,566 | 5/19/2023 |
| 11.0.1.1 | 2,286 | 5/13/2023 |
| 11.0.1 | 10,719 | 4/22/2023 |
| 11.0.0.1 | 1,930 | 4/17/2023 |
| 11.0.0 | 13,303 | 3/25/2023 |
| 10.1.1.1 | 20,495 | 3/12/2023 |
| 10.1.1 | 96,576 | 1/13/2023 |
| 10.1.0.1 | 12,844 | 12/6/2022 |
| 10.1.0 | 29,107 | 10/15/2022 |
| 10.0.1.1 | 31,280 | 10/2/2022 |
| 10.0.1 | 61,130 | 6/4/2022 |
| 10.0.0.1 | 13,380 | 4/29/2022 |
| 10.0.0 | 48,596 | 2/3/2022 |
| 1.1.1.1 | 47,522 | 9/12/2021 |
| 1.1.1 | 1,617 | 8/25/2021 |
| 1.1.0.1 | 1,052 | 8/23/2021 |
| 1.1.0 | 1,935 | 8/7/2021 |
| 1.0.1.1 | 17,981 | 5/17/2021 |
| 1.0.1 | 1,257 | 4/27/2021 |
| 1.0.0.1 | 3,049 | 1/23/2021 |
| 1.0.0 | 2,113 | 12/19/2020 |
| 0.1.1.1 | 3,661 | 12/12/2020 |
| 0.1.1 | 1,186 | 12/6/2020 |
| 0.1.0.1 | 1,551 | 9/27/2020 |
| 0.1.0 | 1,309 | 9/13/2020 |
| 0.0.1.1 | 1,239 | 8/7/2020 |
| 0.0.1 | 1,244 | 7/29/2020 |
| 0.0.0.1 | 1,789 | 7/21/2020 |