gitlabEdit

computerHow to use

How do you use this library?

This library is simple to use compared to Inxi.NET. It allows you to get information about your hardware installed on your PC.


Obtaining hardware information

You can selectively parse hardware and get information for each part that is currently supported by SpecProbe.

chevron-rightSupported typeshashtag

The following hardware types are supported:

Function
Type

HardwareProber.GetProcessor()

Processor (CPU)

HardwareProber.GetVideos()

Graphics Card (GPU)

HardwareProber.GetMemory()

System Memory (RAM)

HardwareProber.GetHardDisks()

Storage Devices (HDD, SSD, NVMe, eMMC, ...)

Once you call these functions, the parser relevant to the part that you need to get information will try to fetch info from the hardware in native ways.

circle-info

SpecProbe caches hardware information once they're fetched. You can invalidate the cache using the InvalidateCache() function from the same class for benchmarking and other purposes.


Obtaining software information

In addition to the hardware parser that SpecProbe provides, this library also provides a separate NuGet package, SpecProbe.Software, that allows you to get software information, including your kernel version.

chevron-rightObtaining the kernel versionhashtag

Just use the UnameManager class that contains:

Function
Description

GetUname()

Gets info about the kernel according to the uname type.

This function queries information about your kernel and its basic information, like your system architecture and your kernel version, based on the passed uname flags. Currently, it supports all the portable flags in UnameTypes:︎

Flag
Description

KernelName

Kernel name

KernelRelease

Kernel release

KernelVersion

Kernel version

NetworkNode

Network host name

Machine

Machine architecture

OperatingSystem

Operating system

chevron-rightObtaining operating system type querieshashtag

You can also query the operating system of your choice using functions defined in the PlatformHelper class.

Function
Description

IsOnWindows()

Checks to see if the application is running under Windows

IsOnWindowsOrWsl()

Checks to see if the application is running under either Windows or WSL

IsOnUnix()

Checks to see if the application is running under Linux and other Unix-based systems

IsOnMacOS()

Checks to see if the application is running under macOS, which is a BSD-based Unix operating system

IsOnAndroid()

Checks to see if the application is running under Android, which is a Linux-based system

GetPlatform()

Gets the platform in an enumeration

chevron-rightObtaining system architecture querieshashtag

You can also query the system architecture of your choice using functions defined in the PlatformHelper class.

Function
Description

IsOnArmOrArm64()

Checks to see if the application is running under either ARM or ARM64

IsOnArm()

Checks to see if the application is running under ARM (32-bit)

IsOnArm64()

Checks to see if the application is running under ARM64

IsOnX86OrAmd64()

Checks to see if the application is running under either x86 or AMD64

IsOnAmd64()

Checks to see if the application is running under AMD64

IsOnX86()

Checks to see if the application is running under x86

GetArchitecture()

Gets the architecture in an enumeration

chevron-rightObtaining C library type queries (Unix)hashtag

You can also query the C library type of your choice using functions defined in the PlatformHelper class.

Function
Description

IsOnUnixMusl()

Checks to see if the libc library is a musl implementation or not

IsOnUnixWsl()

Checks to see if this Linux flavor is a WSL distribution

chevron-rightObtaining terminal environment type queries (Unix)hashtag

You can also query the terminal environment type of your choice using functions defined in the PlatformHelper class.

Function
Description

GetTerminalEmulator()

Gets the terminal emulator by polling the TERM_PROGRAM environment variable

GetTerminalType()

Gets the emulated terminal type by polling the TERM environment variable

chevron-rightObtaining environment and runtime type querieshashtag

You can also query the environment and runtime type of your choice using functions defined in the PlatformHelper class.

Function
Description

IsRunningFromGrilo()

Checks to see whether this program has been executed from GRILO, an obsolete program

IsRunningFromNitrocid()

Checks to see whether this program has been executed from Nitrocid's bootloader or from Nitrocid's modding feature

IsRunningFromTmux()

Checks to see whether this terminal is a TMUX terminal

IsRunningFromScreen()

Checks to see whether this terminal is a GNU Screen terminal

IsRunningFromMono()

Checks to see whether this appiication is run from Mono Runtime or not

IsDotNetFx()

Checks to see whether this application is run from .NET Framework on Windows

GetCurrentGenericRid()

Gets the current generic RID (doesn't describe specific distribution), optionally specifying whether MUSL is included in the queries

chevron-rightObtaining graphical environment type querieshashtag

You can also query the graphical environment type of your choice using functions defined in the PlatformHelper class.

Function
Description

IsOnGui()

Checks to see whether the current environment is a GUI environment or not (always true on macOS, Windows, and Android)

IsOnX11()

Checks to see whether the GUI framework used is either an X.Org server or an XWayland server (false on macOS, Windows, and Android)

IsOnWayland()

Checks to see whether the GUI framework used is a Wayland server (false on macOS, Windows, and Android)

chevron-rightObtaining PATH querieshashtag

You can also query PATH directories using functions defined in the PlatformHelper class.

Function
Description

GetPaths()

Gets a list of PATH directories as an array

GetPossiblePaths()

Takes a file name and queries it by checking every single PATH appended with the file name for existence, then returns an array of paths that this file is found on


Device IDs

SpecProbe manages all device IDs according to the available databases. Currently, as of 3.2.0, it provides two types of such database.

chevron-rightPCI (Peripheral Component Interconnect) IDshashtag

SpecProbe now manages PCI IDs for all known devices that you can find in the PCI ID database that you can download herearrow-up-right. You can use the PciListParser class that lets you get vendors, devices, subdevices, and get their information. It also contains device class management.

chevron-rightUSB (Universal Serial Bus) IDshashtag

SpecProbe manages USB IDs for all known USB devices ranging from USB mass storage devices to external hard drives to mouses and keyboards. This is based on a database of known USB devices that you can download herearrow-up-right. You can use the UsbListParser class that lets you get the following:

  • Vendors

    • Device

      • Protocol

  • Classes

    • Subclasses

  • Audio terminals

  • Video terminals

  • Human Interface Devices (HIDs)

  • HID items

  • Physical biases

  • Physical descriptors

  • HID usage pages

    • HID usages

  • Languages

    • Dialects

  • Country codes


Native Libraries

SpecProbe.Loader contains a class that manages how to load the libraries according to both the operating system and the architecture specification using different paths, called LibraryManager. This allows you to load native libraries by copying the native library file or stream to a file in the application executable directory.

1

Obtain a path to a native library file

You'll need to get a path to the native library file using a file path that you've specified. Make sure that you point those paths to the correct library file for your operating system and your processor architecture.

2

Load all native libraries

Once you're done creating new instances of library manager classes, you can now load all of them when needed, as in LoadNativeLibrary().

3

Verify that native libraries are loaded

To verify that it's truly loaded, use the GetNativeMethodDelegate<T>() method, pointing the generic type argument to your function delegate that matches the native library signatures.

Here are some of the examples of how to load such libraries:

chevron-rightCreating a new instance of the library manager from a file pathhashtag
chevron-rightCalling a native library functionhashtag

Environment tools

SpecProbe also implements a class called EnvironmentTools that allows you to use the functions related to querying and setting environment variables for native libraries. Currently, you can get and set an environment variable with the below methods, according to the scope.

chevron-rightUsing .NET (managed)hashtag

This uses the Environment.GetEnvironmentVariable()arrow-up-right function and the Environment.SetEnvironmentVariable()arrow-up-right function, but it might not be effective for some native libraries on Windows and all native libraries on Unix.

  • GetEnvironmentVariableManaged()

  • SetEnvironmentVariableManaged()

  • SetEnvironmentVariableAppendManaged()

  • SetEnvironmentVariableNoOverwriteManaged()

chevron-rightUsing UCRT (for Windows libraries built with UCRT)hashtag

This uses the getenv_s()arrow-up-right function and the _putenv_s()arrow-up-right function, and it's effective for UCRT-based native libraries built for Windows.

  • GetEnvironmentVariableUcrt()

  • SetEnvironmentVariableUcrt()

  • SetEnvironmentVariableAppendUcrt()

  • SetEnvironmentVariableNoOverwriteUcrt()

chevron-rightUsing LIBC (for Unix native libraries)hashtag

Using LIBC: This uses the getenv()arrow-up-right function and the setenv()arrow-up-right function, and it's effective for Unix native libraries.

  • GetEnvironmentVariableLibc()

  • SetEnvironmentVariableLibc()

  • SetEnvironmentVariableAppendLibc()

  • SetEnvironmentVariableNoOverwriteLibc()

Last updated