Which Operating System - July 1998

In July 1998 I updated modOS.bas to support Windows 98. It became the tip-of-the-month. In December 1999 I updated the module to support Windows 2000. In October 2000 I updated modOS.bas to support Windows Me. In October 2001 I added support for Windows XP versions. In December 2001 I added a test for the Home versus the Professional version of XP. In March 2007 I added support for Vista.

2001/12/14 - I changed the method used to determine the XP Home versus Pro versions. You should replace modOS.bas with the version dated 2001/12/14.

2007/03/14 - I added support for Vista. You should replace modOS.bas with the version dated 2007/03/14.

I have tested the routines with Windows 95/98/NT/2000/Me/XP/Vista. If you would test it with your operating system and send me a 'jpg' screen shot I will include it on this web page.

Add NT Version - May 2001

May 2001 - I added function WhichNT. This function reads the registry and returns the NT version. The code is based loosely upon C++ code found in a Microsoft article "Which Windows NT (Server or Workstation) Is Running?"

Sample Program

I wrote a small sample program that calls functions in modOS and modWhichNT to demonstrate the values returned. I ran the demo on many different operating systems. 

Windows 2000 LanmanNT

Windows Millennium

Windows NT

Windows 98

Windows 95

Module modOS

modOS.bas contains 16 [a few] and 32 bit functions which return various operating system information. Functions include:

Win31, Win95, Win98, WinMe, WinNT, Win2K, WinXP, Vista

These functions can be called with or without arguments. For example:

If Win2K() Then
    ... do win2K items
End If

Or they can be called with arguments [used in the first sample above], for example:

Dim ma as Integer, mi as Integer, bl As Long
Dim spma, spmi
Dim sCSDVersion As String
If Win2K(ma, mi, bl, , sCSDVersion, spma, spmi) Then
    Text1.Text = " Win2K = True [" & BuildOSVersionString("Win2K", ma, mi, bl, sCSDVersion, spma, spmi) & "]"
    Text1.Text = " Win2K = False"
End If

API GetVersion and GetVersionEx

APIs GetVersion and GetVersionEx are used in modOS.bas to retrieve version information. The use of those APIs is described in that module. GetVersionExV5 was added, in December 1999, as an alias to support the version 5 structure [OSVersionInfoEX] available in Win2K. It returns service pack major and minor version numbers.

Module modWhichNT

Function WhichNT returns the following:

WinNT Windows NT Workstation or Professional
ServerNT Windows NT Server
LanmanNT Windows NT Advanced Server is running (Server as Domain controller)

The Demo Uses modConnectToWebSite

The demo program uses modConnectToWebSite.bas to display this page. For details on the use of that module click here.

Download VB Code

Click here to download the VB 6 Source Code [28k]. Supports VB4 16 and 32 bit as well as VB5, VB6.

Previous Tip    Tip Index    Next Tip


Updated 2009/03/20