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:
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
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
if szCSDVersion[1] has value A, it's Microsoft Windows 98 Second Edition
4
90
Microsoft Windows Millenium Edition [
more info]
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
depending on OSVERSIONINDOEX.wProductType it's Server or Workstation
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
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
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.
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.
can only be Windows 3.11 for Workgroups with the
Win32s addonIt'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.
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 the component as a ZIP file:
mirror 1 is
mirror 2 is
mirror 3 is
(file size: 21.56 kB, last modified: 21.09.2011)
Download the component as a RAR file:
mirror 1 is
mirror 2 is
mirror 3 is
(file size: 19.90 kB, last modified: 21.09.2011)
Download the component resource file below:
mirror 1 is
mirror 2 is
mirror 3 is
(file size: 484 bytes, last modified: 21.09.2011)
last update: 2011-09-22 - 22:37:08.
copyright © by Klaus Burgstaller 2009