a component detecting the Windows version

TWindowsVersion uses several Windows API calls and data structures for gathering information about the running version of Microsoft Windows®. To get the required information, you should use the following Windows API calls and data structures:


function/structure name
found on:
GetVersionEx
how to use can be found in the MSDN Library
OSVERSIONINFOEX
also described in then MSDN-Library
SYSTEM_INFO
also described in then MSDN-Library
GetProductInfo
found in then MSDN-Library
and much more. Read the MSDN Library carefully to find out everything about the Windows version.

The information passed to you through the functions above identifies the Windows version. You then have to use some more info to find out the difference between a Windows XP Professional or Home version, or a Windows Server 2008 and Windows Vista, which use the same major and minor verison number:


major version
minor version
windows version
xxx
xxx
OSVERSIONINFOEX.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS
4
0
Microsoft Windows 95 [more info]
if szCSDVersion[1] has value B, it's Microsoft Windows 95B OSR 2
if szCSDVersion[1] has value C, it's Microsoft Windows 95C OSR 2
4
10
Microsoft Windows 98 [more info]
if szCSDVersion[1] has value A, it's Microsoft Windows 98 Second Edition
4
90
Microsoft Windows Millenium Edition [more info]
xxx
xxx
OSVERSIONINFOEX.dwPlatformId = VER_PLATFORM_WIN32_NT
3
1
Microsoft Windows NT 3.1 [more info]
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
3
5
Microsoft Windows NT 3.5 [more info]
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
3
51
Microsoft Windows NT 3.51 [more info]
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
4
0
Microsoft Windows NT 4.0 [more info]
have a look at OSVERSIONINFOEX.wSuiteMask to indentify these versions:
if flag VER_SUITE_TERMINAL is set, it's NT 4.0 Terminal Server
otherwise look at the registry key
HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions
to find out if it's Server, Advanced Server or Datacenter Server
5
0
Microsoft Windows 2000 [more info]
have a look at OSVERSIONINFOEX.wProductType to see:
if it's VER_NT_WORKSTATION, it's Windows 2000 Professional
otherwise examine OSVERSIONINFOEX.wSuiteMask to find out:
if flag VER_SUITE_DATACENTER is set, it's Windows 2000 Datacenter Server
if flag VER_SUITE_ENTERPRISE is set, it's Windows 2000 Advanced Server
if none of these is set, it's a normal Windows 2000 Server
5
1
is Microsoft Windows XP [more info]
with lots of variants:
    Home Edition
    Professional
    Media Center Edition
    Tablet PC Edition 2005
    Starter Edition
    or Embedded
use GetSystemMetrics to find out exactly
5
2
Microsoft Windows Server 2003, 2003 R2 or Home Server [more info]
5
2
could also be Microsoft Windows XP Professional x64 Edition [more info]
therefore OSVERSIONINFOEX.wProductType = VER_NT_WORKSTATION an
SYSTEM_INFO.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64
6
0
is Microsoft Windows Vista or Windows Server 2008
depending on OSVERSIONINFOEX.wProductType.
the GetProductInfo function identifies what it exactly is.
SYSTEM_INFO.wProcessorArchitecture tells you if it's 32bit or 64bit.
6
1
is Microsoft Windows 7 or Windows Server R2
also with a lot of subversions, and 32bit or 64bit.
xxx
xxx
OSVERSIONINFOEX.dwPlatformId = VER_PLATFORM_WIN32s
can only be Windows 3.11 for Workgroups with the Win32s addon

It's a pretty hard piece of work to find out all the possible versions of Microsoft Windows®. The table above will help you, but the code behind is much more work than you expect! I searched days in the internet to get all the information to put it all together in my component. You need mor time an lots of virtual machines to test the whole thing. So I'm really proud to present the finished component, which will be updated, when new versions of Windows come up. The component also finds out, if Windows started normally, in safe mode and other boot options.


TWindowsVersion:
TWindowsVersion in the Object Inspector





properties of TWindowsVersion in the
Delphi® Object Inspector at design time.

The grey rectangles in the picture
are no error but they should hide the
Windows installation key.

TWindowsVersion   (6.292 bytes)

Have a look at some screenshots to see the output of a sample program running on different Windows version in VMWare. Feel free to contact me to get the source code, if required.


You can download the component and also the component resource file below. Please link to my homepage in your copyright section if you use my component in your own applications!


Download info:
icon  Download the component as a ZIP file:
        mirror 1 is server online   download online     (file size: not determinable, last modified: not determinable)
        mirror 2 is server offline  
        mirror 3 is server online   download online     (file size: 21.56 kB, last modified: 21.09.2011)
icon  Download the component as a RAR file:
        mirror 1 is server online   download online     (file size: not determinable, last modified: not determinable)
        mirror 2 is server offline  
        mirror 3 is server online   download online     (file size: 19.90 kB, last modified: 21.09.2011)
icon  Download the component resource file below:
        mirror 1 is server online   download online     (file size: not determinable, last modified: not determinable)
        mirror 2 is server offline  
        mirror 3 is server online   download online     (file size: 484 bytes, last modified: 21.09.2011)

last update: 2011-09-22 - 22:37:08.
copyright by Klaus Burgstaller 2009