Repository navigation
SysWin Dmi
Home › All Categories › sys/win › 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.
#import "sys/win"
#import "sys/win/dmi"
using win, dmisys/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.
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.
| 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. |
-
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
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Android (experimental)
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Move Semantics
- Match
- Lambdas
- Block Strings
- String Interpolation
- Partial Types
- String Slices
- Array Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Hardware
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- tiko test
- tiko doc
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing