iSMBIOS 1.1.5

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

Install-Package iSMBIOS -Version 1.1.5
dotnet add package iSMBIOS --version 1.1.5
<PackageReference Include="iSMBIOS" Version="1.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add iSMBIOS --version 1.1.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: iSMBIOS, 1.1.5"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

What is iSMBIOS?

iSMBIOS is a lightweight implementation that allows us to obtain the SMBIOS information. Currently only works on Windows

This library implements DMTF Specification 3.4.0 version and olders versions

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

Usage

Before

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

Now

The DMI.Instance property now is mark as obsolete use DMI.CreateInstance() method instead.

For more info, please see CHANGELOG

Examples

  1. Gets and prints SMBIOS version.

    Console.WriteLine($@" SMBIOS Version > {DMI.CreateInstance().SmbiosVersion}");
    
  2. Gets and prints all SMBIOS availables structures.

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName}");
    
        int totalStructures = structure.Elements.Count;
        if (totalStructures > 1)
        {
            Console.WriteLine($@"     > {totalStructures} structures");
        }
    }
    
  3. Gets and prints the implemented SMBIOS structure version.

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName}");
    
        DmiClassCollection elements = structure.Elements;
        foreach (DmiClass element in elements)
        {
            Console.WriteLine($@"     > Version > {element.ImplementedVersion}");
        }
    }
    
  4. Gets a specific SMBIOS structure.

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

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    QueryPropertyResult biosVersion = structures.GetProperty(DmiProperty.Bios.BiosVersion);
    if (biosVersion.Success)
    {
        Console.WriteLine($@" > BIOS Version > {biosVersion.Value.Value}");
    }
    
    QueryPropertyResult currentSpeed = structures.GetProperty(DmiProperty.Processor.CurrentSpeed);
    if (currentSpeed.Success)
    {
        Console.WriteLine($@" > Current Speed > {currentSpeed.Value.Value} {currentSpeed.Value.Key.PropertyUnit}");
    }
    
  6. Prints all SMBIOS structures properties

     DmiStructureCollection structures = DMI.CreateInstance().Structures;      
     foreach (DmiStructure structure in structures)
     {
         DmiClassCollection elements = structure.Elements;
         foreach (DmiClass element in elements)
         {
             Console.WriteLine();
             Console.WriteLine(element.ImplementedVersion == DmiStructureVersion.Latest
                 ? $@" ———————————————————————————————————————————————————— {element.ImplementedVersion} ——"
                 : $@" ——————————————————————————————————————————————————————— {element.ImplementedVersion} ——");
             Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName} structure detail");
             Console.WriteLine(@" ——————————————————————————————————————————————————————————————");
    
             IEnumerable<IPropertyKey> properties = element.ImplementedProperties;
             foreach (var property in properties)
             {
                 QueryPropertyResult queryResult = element.GetProperty(property);
                 PropertyItem propertyItem = queryResult.Value;
                 object value = propertyItem.Value;
                 string friendlyName = property.GetPropertyName();
                 PropertyUnit valueUnit = property.PropertyUnit;
                 string unit = valueUnit == PropertyUnit.None ? string.Empty : valueUnit.ToString();
                 if (value == null)
                 {
                     Console.WriteLine($@" > {friendlyName} > NULL");
                     continue;
                 }
    
                 if (value is string)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit}");
                 }
                 else if (value is byte)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X2}h]");
                 }
                 else if (value is short)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is ushort)
                 {
                     Console.WriteLine(property.Equals(DmiProperty.MemoryDevice.ConfiguredMemoryClockSpeed)
                         ? $@" > {friendlyName} > {value} {(int.Parse(dmi.SmbiosVersion) > 300 ? PropertyUnit.MTs : PropertyUnit.MHz)} [{value:X4}h]"
                         : $@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is int)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is uint)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is long)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X8}h]");
                 }
                 else if (value is ulong)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X8}h]");
                 }
                 else if (value.GetType() == typeof(ReadOnlyCollection<byte>))
                 {
                     Console.WriteLine($@" > {friendlyName} > {string.Join(", ", (ReadOnlyCollection<byte>)value)}");
                 }
                 else if (value is DmiGroupAssociationElementCollection)
                 {
                     // prints elements
                 }
                 else if (value.GetType() == typeof(ReadOnlyCollection<string>))
                 {
                     Console.WriteLine($@" > {friendlyName}");
                     var collection = (ReadOnlyCollection<string>)value;
                     foreach (var entry in collection)
                     {
                         Console.WriteLine($@"   > {entry} {unit}");
                     }
                 }
                 else
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit}");
                 }
             }
         }
     }
    

Changes

For more information, please visit the next link CHANGELOG

What is iSMBIOS?

iSMBIOS is a lightweight implementation that allows us to obtain the SMBIOS information. Currently only works on Windows

This library implements DMTF Specification 3.4.0 version and olders versions

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

Usage

Before

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

Now

The DMI.Instance property now is mark as obsolete use DMI.CreateInstance() method instead.

For more info, please see CHANGELOG

Examples

  1. Gets and prints SMBIOS version.

    Console.WriteLine($@" SMBIOS Version > {DMI.CreateInstance().SmbiosVersion}");
    
  2. Gets and prints all SMBIOS availables structures.

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName}");
    
        int totalStructures = structure.Elements.Count;
        if (totalStructures > 1)
        {
            Console.WriteLine($@"     > {totalStructures} structures");
        }
    }
    
  3. Gets and prints the implemented SMBIOS structure version.

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    foreach (DmiStructure structure in structures)
    {
        Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName}");
    
        DmiClassCollection elements = structure.Elements;
        foreach (DmiClass element in elements)
        {
            Console.WriteLine($@"     > Version > {element.ImplementedVersion}");
        }
    }
    
  4. Gets a specific SMBIOS structure.

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

    DmiStructureCollection structures = DMI.CreateInstance().Structures;
    QueryPropertyResult biosVersion = structures.GetProperty(DmiProperty.Bios.BiosVersion);
    if (biosVersion.Success)
    {
        Console.WriteLine($@" > BIOS Version > {biosVersion.Value.Value}");
    }
    
    QueryPropertyResult currentSpeed = structures.GetProperty(DmiProperty.Processor.CurrentSpeed);
    if (currentSpeed.Success)
    {
        Console.WriteLine($@" > Current Speed > {currentSpeed.Value.Value} {currentSpeed.Value.Key.PropertyUnit}");
    }
    
  6. Prints all SMBIOS structures properties

     DmiStructureCollection structures = DMI.CreateInstance().Structures;      
     foreach (DmiStructure structure in structures)
     {
         DmiClassCollection elements = structure.Elements;
         foreach (DmiClass element in elements)
         {
             Console.WriteLine();
             Console.WriteLine(element.ImplementedVersion == DmiStructureVersion.Latest
                 ? $@" ———————————————————————————————————————————————————— {element.ImplementedVersion} ——"
                 : $@" ——————————————————————————————————————————————————————— {element.ImplementedVersion} ——");
             Console.WriteLine($@" {(int)structure.Class:D3}-{structure.FriendlyClassName} structure detail");
             Console.WriteLine(@" ——————————————————————————————————————————————————————————————");
    
             IEnumerable<IPropertyKey> properties = element.ImplementedProperties;
             foreach (var property in properties)
             {
                 QueryPropertyResult queryResult = element.GetProperty(property);
                 PropertyItem propertyItem = queryResult.Value;
                 object value = propertyItem.Value;
                 string friendlyName = property.GetPropertyName();
                 PropertyUnit valueUnit = property.PropertyUnit;
                 string unit = valueUnit == PropertyUnit.None ? string.Empty : valueUnit.ToString();
                 if (value == null)
                 {
                     Console.WriteLine($@" > {friendlyName} > NULL");
                     continue;
                 }
    
                 if (value is string)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit}");
                 }
                 else if (value is byte)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X2}h]");
                 }
                 else if (value is short)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is ushort)
                 {
                     Console.WriteLine(property.Equals(DmiProperty.MemoryDevice.ConfiguredMemoryClockSpeed)
                         ? $@" > {friendlyName} > {value} {(int.Parse(dmi.SmbiosVersion) > 300 ? PropertyUnit.MTs : PropertyUnit.MHz)} [{value:X4}h]"
                         : $@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is int)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is uint)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X4}h]");
                 }
                 else if (value is long)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X8}h]");
                 }
                 else if (value is ulong)
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit} [{value:X8}h]");
                 }
                 else if (value.GetType() == typeof(ReadOnlyCollection<byte>))
                 {
                     Console.WriteLine($@" > {friendlyName} > {string.Join(", ", (ReadOnlyCollection<byte>)value)}");
                 }
                 else if (value is DmiGroupAssociationElementCollection)
                 {
                     // prints elements
                 }
                 else if (value.GetType() == typeof(ReadOnlyCollection<string>))
                 {
                     Console.WriteLine($@" > {friendlyName}");
                     var collection = (ReadOnlyCollection<string>)value;
                     foreach (var entry in collection)
                     {
                         Console.WriteLine($@"   > {entry} {unit}");
                     }
                 }
                 else
                 {
                     Console.WriteLine($@" > {friendlyName} > {value} {unit}");
                 }
             }
         }
     }
    

Changes

For more information, please visit the next link CHANGELOG

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.5 1,335 10/12/2020
1.1.4 929 8/25/2020
1.1.3 2,221 3/6/2020
1.1.2 239 2/15/2020
1.1.1 2,478 10/20/2019
1.1.0 226 9/2/2019
1.0.9 185 8/28/2019
1.0.8 212 8/23/2019
1.0.7 220 8/13/2019
1.0.6 275 5/29/2019
1.0.5 274 4/25/2019
1.0.3 229 4/12/2019
1.0.2 220 4/2/2019
1.0.1 291 3/22/2019
1.0.0 948 12/29/2018