Repository navigation
SysWin Windows Version
Home › All Categories › sys/win › Windows version and system
Reports the Windows version, build, edition and bitness, and the version of any file.
The version functions ask the system kernel directly, so they return the real version whatever
the program's manifest says. The older GetVersionExW call does not: in a program without a
manifest it reports 6.2, build 9200 (Windows 8), even on Windows 11. Windows 10 and Windows 11 both report version 10.0; tell them
apart by the build number, which is 22000 or higher on Windows 11.
Versions are returned as one number, the major version times 100 plus the minor version:
1000 for 10.0, 601 for 6.1, 582 for 5.82.
#import "sys/win"
using winA console program that describes the Windows it runs on:
#import "sys/win"
using win
function main() as long
dim nBuild as long = GetWindowsBuild()
dim ustrName as ustring
if GetWindowsMajorVersion() = 10 andalso nBuild >= 22000 then
ustrName = "Windows 11"
else
ustrName = "Windows " & GetWindowsMajorVersion() & "." & GetWindowsMinorVersion()
end if
print ustrName; " "; GetWindowsFeatureUpdate(); ", build"; nBuild; ","; GetWindowsBitness(); "-bit"
print "version number:"; GetWindowsVersion()
print "user32.dll version:"; GetFileVersion( "user32.dll" )
return 0
end function
end main()On a 64-bit Windows 11, build 26300, it prints Windows 11 26H2, build 26300, 64-bit, then
version number: 1000 and user32.dll version: 1000.
| Function | Does |
|---|---|
| GetWindowsVersion | Returns the Windows version as one number, 1000 for 10.0. |
| GetWindowsMajorVersion | Returns the major version, 10 on Windows 10 and 11. |
| GetWindowsMinorVersion | Returns the minor version, 0 on Windows 10 and 11. |
| GetWindowsBuild | Returns the build number. |
| GetWindowsBitness | Returns 64 on a 64-bit Windows, 32 on a 32-bit one. |
| GetWindowsProductType | Returns the edition, as a PRODUCT_* value. |
| GetWindowsFeatureUpdate | Returns the feature update name, such as 26H2. |
| GetFileVersion | Returns the version of a file as one number. |
| ShowSysInfo | Opens the System Information program. |
| GetMACAddress | Returns the hardware address of a network adapter. |
function GetWindowsVersion() as longReturns the version of Windows as the major version times 100 plus the minor version.
| Value | Windows |
|---|---|
| 600 | Vista, Server 2008 |
| 601 | 7 |
| 602 | 8 |
| 603 | 8.1 |
| 1000 | 10 and 11, Server 2016 and later |
Returns the version, or 0 if it could not be read.
Example
if GetWindowsVersion() < 1000 then print "this program needs Windows 10 or later"Microsoft Learn: RtlGetVersion
function GetWindowsMajorVersion() as longReturns the major version of Windows: 10 on Windows 10 and Windows 11, 6 on Vista to 8.1.
Returns the major version, or 0 if it could not be read.
Example
print "major version:"; GetWindowsMajorVersion()function GetWindowsMinorVersion() as longReturns the minor version of Windows: 0 on Windows 10 and Windows 11, 1 on Windows 7.
Returns the minor version, or 0 if it could not be read.
Example
print "Windows"; GetWindowsMajorVersion(); "."; GetWindowsMinorVersion()function GetWindowsBuild() as longReturns the build number of Windows. It is 22000 or higher on Windows 11, lower on Windows 10.
Returns the build number, or 0 if it could not be read.
Example
if GetWindowsBuild() >= 22000 then print "Windows 11"function GetWindowsBitness() as longReturns the bitness of the operating system, not of the program: 64 on an x64 or ARM64 Windows, 32 otherwise.
Returns 64 or 32.
Example
print GetWindowsBitness(); "-bit Windows"Microsoft Learn: GetNativeSystemInfo
function GetWindowsProductType() as DWORDReturns the edition of Windows installed, as one of the PRODUCT_* values: for example
PRODUCT_PROFESSIONAL (&h30) for Pro, PRODUCT_CORE (&h65) for Home and
PRODUCT_ENTERPRISE (&h04) for Enterprise.
Returns the PRODUCT_* value, or PRODUCT_UNDEFINED (0) if it could not be read.
Example
if GetWindowsProductType() = PRODUCT_PROFESSIONAL then print "Windows Pro"Microsoft Learn: GetProductInfo
function GetWindowsFeatureUpdate() as ustringReturns the name of the installed feature update, the twice-yearly release name such as 22H2
or 26H2, as Windows shows it under Settings › System › About. It is read from the
DisplayVersion value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion.
Returns the name, or an empty string on Windows versions that do not record one.
Example
print "feature update: "; GetWindowsFeatureUpdate()Microsoft Learn: RegGetValueW
function GetFileVersion( byval pwszFileName as wstring ptr ) as longReturns the version of a file from its version resource, as the major version times 100 plus the minor version: 610 for 6.10. The build and revision parts are not included. A minor version above 99 runs into the major part, so the number is only unambiguous for minor versions of 0 to 99.
A file name without a path is looked for the way Windows looks for a DLL. So
GetFileVersion( "comctl32.dll" ) returns 582, the version-5 common controls in the system
folder, even in a program that uses version 6 through its manifest.
| Parameter | Meaning |
|---|---|
pwszFileName |
The file: an executable, a DLL or any other file with a version resource. |
Returns the version, or 0 if the file has no version resource or cannot be found.
Example
print "user32.dll:"; GetFileVersion( "user32.dll" ) ' 1000 on Windows 10 and 11Microsoft Learn: GetFileVersionInfoW, VS_FIXEDFILEINFO
function ShowSysInfo( byval hWin as HWND ) as booleanStarts the Windows System Information program (msinfo32.exe), found through the path it
records under HKEY_LOCAL_MACHINE\Software\Microsoft\Shared Tools\MSInfo. It does not wait for
the program to close.
| Parameter | Meaning |
|---|---|
hWin |
The window that owns any error message Windows shows, or NULL. |
Returns true if the program was started; false if its path is not recorded or it could not
be started.
Example
if ShowSysInfo( hwnd ) = false then MsgBox( hwnd, "System Information is not available." )Microsoft Learn: ShellExecuteW
function GetMACAddress() as stringReturns the hardware (MAC) address of a network adapter as six pairs of upper-case hexadecimal
digits joined by dashes, MM-MM-MM-SS-SS-SS: 17 characters. The first three pairs identify the
maker of the adapter.
The address is the one Windows puts into a sequential UUID, so on a computer with several
adapters it is one of them and you cannot choose which. On a computer with no network adapter
Windows makes the address up.
Returns the address, or an empty string if it could not be read.
Example
dim mac as string = GetMACAddress()
if len( mac ) then print "adapter address: "; macMicrosoft Learn: UuidCreateSequential
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
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String 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
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- 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