Windows System Error Messages

The main error system in Windows API are based on integer codes that can be read with GetLastError().

To get an error text message for the error call SysErrorMessage() with the error code.

To find all available errors for a given Windows version and configuration it is possible to use a loop to query SysErrorMessage().

The app below is a command line app that query error messages for a given range. Messages found are stored in a CSV text file. The char encoding is ASCII and escaped C style. The CSV file can be read by LibreOffice Calc or MS Excel, however these spreadsheet apps do not treat escaped single quotes and escaped double quotes correctly.

At command prompt start app with options:
WinSysErrMsgCmd [Start] [BlockLength]

If Start and BlockLength are not specified it defaults to:
Start = 0 => 0
BlockLength = 200 => 200 million

For an exhaustive query of messages i.e. all 4G message codes:
WinSysErrMsgCmd 0 4096

Calls to SysErrorMessage() in a single process are somwehat slow, so exhaustive query can take many hours (e.g. ~8h in test).

For faster result, open more command prompts and run multiple instancies with separate ranges. This works well on a multi core CPU.



App Exe Zip:

Delphi 10 source Zip:

Example CSV output (first 200M), Windows 7:
Example CSV output (first 200M), Windows 10:

License: CC-BY 4.0. Freeware, no warranty. Software Disclaimer.

Reference links

Windows System Error Codes (0-499)
Delphi GetLastError()
Delphi SysErrorMessage()

Tags: Windows System Error messages, Delphi, Object Pascal, Programming

Page link: <>

Edited: 2021-12-11