DEV Community

Cover image for Easy way to get the System Information in .NET
Shayan Firoozi
Shayan Firoozi

Posted on

Easy way to get the System Information in .NET

How to get system information easy and fast in .NET ?

Getting the system information with .NET could cause a huge I/O load on you app or service , specially when you want to get the information about CPU , HDD , Partitions , Drive space , Running Processes , Installed Services or etc...

If you need to get a drive space immediately without awaiting for the WMI (Windows Management Instrumentation) result , so you can use FluentSysInfo.Core library from the NuGet.

The FluentSysInfo.Core will use an internal caching mechanism for preferred System Information(s) with customizable update interval , so whenever you request a System Information , the FluentSysInfo.Core will response to your request almost immediately ๐Ÿ‘

Supported System Information :

โœ” Date Time Info
โœ” OS Info
โœ” Main Board Info
โœ” BIOS Info
โœ” CPU Info
โœ” Physical Memory Info
โœ” Disk , Partition And Drive Info
โœ” Network Interfaces Info
โœ” Graphic Card Info
โœ” Running Processes Info
โœ” Windows Services Info
Enter fullscreen mode Exit fullscreen mode

How To Use โ”

It's really simple to use the FluentSysInfo.Core :

  • Example for the Physical Memory (RAM) Info โฌ‡


Console.WriteLine(new FluentSysInfoCore().GetSystemInfo(FluentSysInfoTypes.PhysicalMemory));

Enter fullscreen mode Exit fullscreen mode

And the result from the FluentSysInfo.Core would be something like this :

{
 "Caption": "Physical Memory",
 "Description": "Physical Memory",
 "Name": "Physical Memory",
 "Manufacturer": "04CB",
 "SerialNumber": "2B960400",
 "Tag": "Physical Memory 0",
 "FormFactor": "8",
 "BankLabel": "BANK 0",
 "Capacity": "8589934592",
 "DataWidth": "64",
 "InterleavePosition": "0",
 "MemoryType": "0",
 "Speed": "2133",
 "TotalWidth": "64",
 "Attributes": "2",
 "ConfiguredClockSpeed": "2133",
 "ConfiguredVoltage": "1200",
 "DeviceLocator": "ChannelA-DIMM0",
 "InterleaveDataDepth": "0",
 "MaxVoltage": "1200",
 "MinVoltage": "1200",
 "SMBIOSMemoryType": "26",
 "TypeDetail": "128"
}
{
 "Caption": "Physical Memory",
 "Description": "Physical Memory",
 "Name": "Physical Memory",
 "Manufacturer": "04CB",
 "SerialNumber": "55960400",
 "Tag": "Physical Memory 1",
 "FormFactor": "8",
 "BankLabel": "BANK 1",
 "Capacity": "8589934592",
 "DataWidth": "64",
 "InterleavePosition": "0",
 "MemoryType": "0",
 "Speed": "2133",
 "TotalWidth": "64",
 "Attributes": "2",
 "ConfiguredClockSpeed": "2133",
 "ConfiguredVoltage": "1200",
 "DeviceLocator": "ChannelA-DIMM1",
 "InterleaveDataDepth": "0",
 "MaxVoltage": "1200",
 "MinVoltage": "1200",
 "SMBIOSMemoryType": "26",
 "TypeDetail": "128"
}
Enter fullscreen mode Exit fullscreen mode
  • Example for the OS Info โฌ‡


  Console.WriteLine(new FluentSysInfoCore().GetSystemInfo(FluentSysInfoTypes.OperatingSystem));

Enter fullscreen mode Exit fullscreen mode

And the result from the FluentSysInfo.Core would be something like this :

{
 "Status": "OK",
 "Name": "Microsoft Windows 10 Enterprise|C:\\Windows|\\Device\\Harddisk1\\Partition3",
 "FreePhysicalMemory": "9428600",
 "FreeSpaceInPagingFiles": "2479588",
 "FreeVirtualMemory": "9278148",
 "Caption": "Microsoft Windows 10 Enterprise",
 "Description": "Removed! ๐Ÿ˜Ž",
 "InstallDate": "9/30/2022 1:36:54 PM",
 "CSName": "Removed! ๐Ÿ˜‰",
 "CurrentTimeZone": "210",
 "Distributed": "False",
 "LastBootUpTime": "3/21/2024 6:56:09 AM",
 "LocalDateTime": "3/21/2024 11:39:42 PM",
 "MaxNumberOfProcesses": "4294967295",
 "MaxProcessMemorySize": "137438953344",
 "NumberOfLicensedUsers": "0",
 "NumberOfProcesses": "222",
 "NumberOfUsers": "2",
 "OSType": "18",
 "SizeStoredInPagingFiles": "2490368",
 "TotalVirtualMemorySize": "19224724",
 "TotalVisibleMemorySize": "16734356",
 "Version": "10.0.19045",
 "BootDevice": "\\Device\\HarddiskVolume10",
 "BuildNumber": "19045",
 "BuildType": "Multiprocessor Free",
 "CodeSet": "1252",
 "CountryCode": "1",
 "DataExecutionPrevention_32BitApplications": "True",
 "DataExecutionPrevention_Available": "True",
 "DataExecutionPrevention_Drivers": "True",
 "DataExecutionPrevention_SupportPolicy": "2",
 "Debug": "False",
 "EncryptionLevel": "256",
 "ForegroundApplicationBoost": "2",
 "Locale": "0409",
 "Manufacturer": "Microsoft Corporation",
 "MUILanguages": "{en-US}",
 "OperatingSystemSKU": "4",
 "OSArchitecture": "64-bit",
 "OSLanguage": "1033",
 "OSProductSuite": "256",
 "PortableOperatingSystem": "False",
 "Primary": "True",
 "ProductType": "1",
 "RegisteredUser": "Shayan",
 "SerialNumber": "00329-00000-00003-AA310",
 "ServicePackMajorVersion": "0",
 "ServicePackMinorVersion": "0",
 "SuiteMask": "272",
 "SystemDevice": "\\Device\\HarddiskVolume12",
 "SystemDirectory": "C:\\Windows\\system32",
 "SystemDrive": "C:",
 "WindowsDirectory": "C:\\Windows"
}
Enter fullscreen mode Exit fullscreen mode
  • How to enable the Fast Response feature ? โฌ‡


  FluentSysInfoCore fluentSysInfoCore = new FluentSysInfoCore();

  fluentSysInfoCore.AddFastResponseAgent(FluentSysInfoTypes.InstalledServices, TimeSpan.FromSeconds(5));
  fluentSysInfoCore.AddFastResponseAgent(FluentSysInfoTypes.RunningProcesses, TimeSpan.FromSeconds(5));

  fluentSysInfoCore.StartAllFastResponseAgents();

Enter fullscreen mode Exit fullscreen mode

The FluentSysInfo.Core has been written in C# and the full source code is available on GitHub.

Top comments (2)

Collapse
 
rojasjo profile image
rojasjo

Is this library multiplatform or is it just for Windows?

Collapse
 
shayanfiroozi profile image
Shayan Firoozi

For now , just for Windowsยฎ