iSMBIOS 1.0.5

There is a newer version of this package available.
See the version list below for details.
Install-Package iSMBIOS -Version 1.0.5
dotnet add package iSMBIOS --version 1.0.5
<PackageReference Include="iSMBIOS" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add iSMBIOS --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: iSMBIOS, 1.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install iSMBIOS as a Cake Addin
#addin nuget:?package=iSMBIOS&version=1.0.5

// Install iSMBIOS as a Cake Tool
#tool nuget:?package=iSMBIOS&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

What is iSMBIOS?

iSMBIOS is a lightweight implementation that allows us to obtain the SMBIOS information

This library fully implements DMTF Specification 3.2.0 and olders versions

For more information, please see https://www.dmtf.org/standards/smbios

Usage

Call DMI.Instance.Structures for gets all SMBIOS structures availables.

Examples

  1. Gets and prints all SMBIOS availables structures.

    DmiStructureCollection structures = DMI.Instance.Structures;
    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine($"{(int) structure.Class:D3}-{structure.Class}");
    }
    
  2. Gets a specific SMBIOS structure.

    DmiStructureCollection structures = DMI.Instance.Structures;
    DmiStructure bios = structures[SmbiosStructure.Bios];
    if (bios != null)
    {
        /// structure exist!!!
    }
    
  3. Gets a single property directly.

    DmiStructureCollection structures = DMI.Instance.Structures;
    object biosVersion = structures.GetProperty(DmiProperty.Bios.BiosVersion);
    if (biosVersion != null)
    {
        Console.WriteLine($" BIOS Version > {biosVersion}");
    }
    
    string biosVendor = structures.GetProperty<string>(DmiProperty.Bios.Vendor);
    Console.WriteLine($" > BIOS Vendor > {biosVendor}");
    
    string processorFamily = structures.GetProperty<string>(DmiProperty.Processor.Family);
    Console.WriteLine($" Processor Family > {processorFamily}");
    
    string processorManufacturer = structures.GetProperty<string>(DmiProperty.Processor.ProcessorManufacturer);
    Console.WriteLine($" Processor Manufacturer > {processorManufacturer}");
    
  4. Gets a property in multiple elements directly.

    // Requires that the Slot Information structure exists in your system
    DmiStructureCollection structures = DMI.Instance.Structures;
    IDictionary<int, object> systemSlots = structures.GetProperties(DmiProperty.SystemSlots.SlotId);
    foreach (KeyValuePair<int, object> systemSlot in systemSlots)
    {
        int element = systemSlot.Key;
        object property = systemSlot.Value;
        Console.WriteLine($" System Slot ({element}) > {property}");
    }
    
  5. Prints all SMBIOS structures properties

    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine();
        Console.WriteLine(" ——————————————————————————————————————————————————————————————");
        Console.WriteLine($" {(int)structure.Class:D3}-{structure.Class} structure detail");
        Console.WriteLine(" ——————————————————————————————————————————————————————————————");
        DmiClassCollection elements = structure.Elements;
        foreach (DmiClass element in elements)
        {
            Hashtable elementProperties = element.Properties;
            foreach (DictionaryEntry property in elementProperties)
            {
                object value = property.Value;
    
                PropertyKey key = (PropertyKey)property.Key;
                Enum id = key.PropertyId;
    
                PropertyUnit valueUnit = key.PropertyUnit;
                string unit =
                    valueUnit == PropertyUnit.None
                        ? string.Empty
                        : valueUnit.ToString();
    
                if (value == null)
                {
                    Console.WriteLine($"{id} -> NULL");
                    continue;
                }
    
                if (value is string)
                {
                    Console.WriteLine($"   > {id} > {value}{unit}");
                }
                else if (value is byte)
                {
                    Console.WriteLine($"   > {id} > {value}{unit} [{value:X2}h]");
                }
                else if (value is short)
                {
                    Console.WriteLine($"   > {id} > {value}{unit} [{value:X4}h]");
                }
                else if (value is ushort)
                {
                     Console.WriteLine($"   > {id} > {value}{unit} [{value:X4}h]");
                }
                else if (value is int)
                {
                    Console.WriteLine($@"   > {id} > {value}{unit} [{value:X4}h]");
                }
                else if (value is uint)
                {
                    Console.WriteLine($"   > {id} > {value}{unit} [{value:X4}h]");
                }
                else if (value is long)
                {
                    Console.WriteLine($@"   > {id} > {value}{unit} [{value:X8}h]");
                }
                else if (value is ulong)
                {
                    Console.WriteLine($"   > {id} > {value}{unit} [{value:X8}h]");
                }
                else if (value.GetType() == typeof(ReadOnlyCollection<byte>))
                {
                    Console.WriteLine($"   > {id} > {string.Join(", ", (ReadOnlyCollection<byte>)value)}");
                }
                else if (value.GetType() == typeof(ReadOnlyCollection<string>))
                {
                    Console.WriteLine($"   > {id}");
                    var collection = (ReadOnlyCollection<string>) value;
                    foreach (var entry in collection)
                    {
                        Console.WriteLine($"     > {entry}");
                    }
                }
                else
                {
                    Console.WriteLine($"   > {id} > {value}{unit}");
                }
            }
        }
    }
    

Changes

  • v1.0.5 (This Version)

    • Added iTin.Core.Interop project for interop calls.
    • Added the GetProperty method was added in the class DmiClass, to directly recover a property, this allows us to consider a specification as a bag of consultable properties, for more information, please see how to use it in the example project. On the other hand later when there are more implemented specifications the use of the DeviceProperty type will allow us to and consult properties in different "bags".
    • Minor changes.
  • v1.0.4 (DO NOT USE, version with defects)

    • Added iTin.Core.Interop project for interop calls.
    • Added the GetProperty method was added in the class DmiClass, to directly recover a property, this allows us to consider a specification as a bag of consultable properties, for more information, please see how to use it in the example project. On the other hand later when there are more implemented specifications the use of the DeviceProperty type will allow us to and consult properties in different "bags".
    • Minor changes.
  • v1.0.3

    • Added support for Type 43 [TPM Device].
    • Added native interop functions for handle the firmware tables.
    • Now first we try to get the BIOS data through a native call, if this fails, the call will be made through WMI.
    • Added two new methods to DmiStructureCollection class that allow you to consult a property directly. For more information, please see GetProperty and GetProperties.
    • Minor changes.
  • v1.0.2

    • Update Structure Type 42, Minor changes
  • v1.0.1

    • Solves a problem with Int32Extensions (Thanks to DexterWoo)
  • v1.0.0

    • First release version

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.5 3,352 10/12/2020
1.1.4 996 8/25/2020
1.1.3 2,298 3/6/2020
1.1.2 292 2/15/2020
1.1.1 2,829 10/20/2019
1.1.0 285 9/2/2019
1.0.9 240 8/28/2019
1.0.8 265 8/23/2019
1.0.7 270 8/13/2019
1.0.6 327 5/29/2019
1.0.5 342 4/25/2019
1.0.3 290 4/12/2019
1.0.2 269 4/2/2019
1.0.1 342 3/22/2019
1.0.0 1,005 12/29/2018