Skip to content

SysWin Dmi

Paul Squires edited this page Nov 30, 2026 · 1 revision

Home › All Categories › sys/win › sys/win/dmi

sys/win/dmi

Reads the computer's firmware tables and asks its disks about themselves.

DMI, the Desktop Management Interface, is how a PC describes its own hardware. The firmware keeps the description as SMBIOS tables: one structure for the BIOS, one for the system, one for the motherboard, the chassis, each processor and each memory slot, holding names, serial numbers, speeds and flags. Windows hands a copy of the tables to any program, without administrator rights, through GetSystemFirmwareTable. The module also talks to disk drivers directly with DeviceIoControl, for the geometry, size, model and serial number of a disk.

The module has three parts:

  • CBiosTable, a class that loads the SMBIOS tables, finds the structure of one type and reads its strings and numbers by offset.
  • Firmware functions: the BIOS vendor, version, release date and ROM size, the system UUID, and the structures that describe the tables.
  • Disk functions: a disk's size, geometry, media type, model and serial number, and the disk a volume such as C: is on.

Errors. The firmware functions return an empty string or 0 when the firmware does not supply a value. The disk functions return a tuple, the value and a Windows error code that is 0 on success; GetWinErrMsg turns the code into text.

sys/win/dmi is the work of José Roca.

Importing

#import "sys/win"
#import "sys/win/dmi"
using win, dmi

sys/win/dmi does not import sys/win itself; import it too for GetWinErrMsg and the other helpers. The module brings in windows.bi and win/winioctl.bi, so DISK_GEOMETRY_EX, STORAGE_DEVICE_DESCRIPTOR, MEDIA_TYPE and the IOCTL_* codes are there in any file that imports it.

Example

A console program that describes the machine it runs on:

#import "sys/win"
#import "sys/win/dmi"
using win, dmi

function main() as long
    print "BIOS:   "; GetBiosVendor(); " "; GetBiosVersion(); ", "; GetBiosReleaseDate()
    print "System: "; CBiosTable( 1 ).GetString( &h04 ); " "; CBiosTable( 1 ).GetString( &h05 )
    print "Board:  "; CBiosTable( 2 ).GetString( &h04 ); " "; CBiosTable( 2 ).GetString( &h05 )
    print "CPU:    "; trim( CBiosTable( 4 ).GetString( &h10 ) )
    print "UUID:   "; SMBIOS_GetSystemUUID()

    var (nSize, dwErr) = GetDiskSize( "//./PhysicalDrive0" )
    if dwErr then
        print "Disk 0: "; GetWinErrMsg( dwErr )
    else
        print "Disk 0:"; nSize \ 1000000000; " GB, serial "; GetDeviceSerialNumber( "//./PhysicalDrive0" ).serialNumber
    end if
    print "C: is on PhysicalDrive"; GetVolumeDiskNumber( "//./C:" )
    return 0
end function

end main()

On one desktop it prints (its serial number and UUID replaced here):

BIOS:   American Megatrends Inc. 2214, 01/02/2024
System: ASUS System Product Name
Board:  ASUSTeK COMPUTER INC. ROG STRIX B650-A GAMING WIFI
CPU:    AMD Ryzen 9 7950X3D 16-Core Processor
UUID:   12345678-9ABC-DEF0-0123-456789ABCDEF
Disk 0: 2048 GB, serial 1234567890123
C: is on PhysicalDrive 1

What the firmware fills in is up to the maker: "System Product Name" above is the placeholder a board maker left in. A virtual machine reports the hypervisor's values.

Pages

Page What it does
CBiosTable Loads the SMBIOS firmware tables and reads the strings and numbers of one structure.
Firmware functions Returns the BIOS vendor, version, date and ROM size and the system UUID.
Disk functions Returns a disk's size, geometry, model and serial number, and the disk a volume is on.

See also

  • Hardware: std/hardware, the machine, its firmware, CPU and disks on Windows, Linux and macOS alike
  • Windows version and system: the Windows version, edition and bitness, and a network adapter's address
  • SMBIOS specification (DMTF): every structure type and the offset of every field

Clone this wiki locally