DtWinVer
v1.3
Features
Enclosed is a routine which provides a
comprehensive method to determine which OS the program that calls it is running on. All
methods it uses are fully documented on various articles on the MSDN CD. The routine
provides the emulated OS as well as the underlying OS. e.g to a Dos program Windows 95
looks like MS-DOS 7.0. A full list of the OSs it can detect are:
- Dos
- Windows 3.0
- Windows 3.1
- Windows 3.11
- Windows for Workgroups
- Win32s (if you can call this
an OS <g>)
- Windows CE 1.0
- Windows CE 2.0
- Windows CE 2.1
- Windows CE 2.11
- Windows CE 3.0
- Windows 95
- Windows 95 Service Pack 1
- Windows 95 OEM Service Release
2
- Windows 98
- Windows 98 Second Edition
- NT Workstation, Server 3.1
- NT Workstation, Server, PDC,
BDC 3.5
- NT Workstation, Server, PDC,
BDC 3.51
- NT Workstation, Server, PDC,
BDC 4.0
- Windows 2000 Professional
- Windows 2000 Server / Advanced
Server
- Windows NT Terminal Server
Some of the possible scenarios it can
report on are:
- "You are running an emulated Dos v5.50
On NT"
- "You are running an emulated Windows
3.95 on Windows 95 v4.0 Build 950"
- "You are running Windows for Workgroups
on Dos v6.22"
- "You are running NT Server v3.51"
- "You are running an
application on Windows NT Terminal Server.
- This NT machine is acting as a
stand alone server, primary domain controller or backup domain controller.
History
v1.1 (8 May 1997)
- Fix to remove Unicode and TCHAR
code when
being compiled for Win16.
v1.2 (13 September 1998)
- Updated the sample app plus the
DtWinVer
code to explicitly support Windows 98.
v1.3 (13 September 1998)
- UNICODE enabled the code.
- Removed need for the dwOSVersionInfoSize variable.
- Added support for detecting Build Number of 95 and 98 from DOS code path.
- Now ships as standard with VC 5 workspace files.
- Added explicit support for Windows 95 SP 1.
- Added explicit support for Windows 95 OSR 2.
- Added explicit support for Windows 98 Second Edition.
- Added explicit support for Windows 2000.
- Added explicit support for Windows CE.
- Added explicit support for Windows Terminal Server's.
- Added explicit support for NT Stand Alone Server's.
- Added explicit support for NT Primary Domain Controller's.
- Added explicit support for NT Backup Domain Controller's.
API
GetOSVersion
BOOL GetOSVersion(LPOS_VERSION_INFO
lpVersionInformation)
Parameters
lpVersionInformation A pointer to
a structure of the following form:
- typedef struct _OS_VERSION_INFO
- {
- //What version of OS is being emulated
- DWORD dwEmulatedMajorVersion;
- DWORD dwEmulatedMinorVersion;
- DWORD dwEmulatedBuildNumber;
- DWORD dwEmulatedPlatformId;
- #ifdef _WIN32
- TCHAR szEmulatedCSDVersion[128];
- #else
- char szEmulatedCSDVersion[128];
- #endif
- //What version of OS is really running
- DWORD dwUnderlyingMajorVersion;
- DWORD dwUnderlyingMinorVersion;
- DWORD dwUnderlyingBuildNumber;
- DWORD dwUnderlyingPlatformId;
- #ifdef _WIN32
- TCHAR szUnderlyingCSDVersion[128];
- #else
- char szUnderlyingCSDVersion[128];
- #endif
- } OS_VERSION_INFO, *POS_VERSION_INFO, FAR
*LPOS_VERSION_INFO;
This will be filled in upon a successful
return from the function.
Return Value
TRUE if the function was successful
otherwise FALSE.
Notes
The code uses some C++isms and uses
MFC header files. If you want, it would be a very simple matter of commenting
out a few lines
here and there to get it to work on any standard "C" compiler on any PC OS. 3
mak files are also included which builds a simple application which reports the OS
version, through a message box on Windows and stdio in Dos.
The mak files are:
- dosver.mak (VC 1.5x for Dos)
- winver.mak (VC 1.5x for Win16)
- winver32.dsp/dsw (VC 5 for Win32).
Areas where the code may prove useful are:
- A Dos program wants to know if it can be
allowed access to hardware ports which is not available on NT, but is available on Dos,
Windows 3.x & Windows 95.
- A Win32 program wants to know if the Windows
95 UI is available.
- A Win16 program wants to know if it can call
the Win32 API via generic thunking.
- Checking for the existence of
a certain Service pack on Windows 95 or 98.
Planned
Enhancements
- Add support for Windows 2000
Advanced Server.
- Add support for Windows 2000
Datacenter Server.
- Add support for Embedded
Windows NT.
- Add support for
differentiating between NT Server / Workstation from 16 bit Windows code
path.
Contacting
the Author
PJ Naughter
Email: pjn@indigo.ie
Web: http://indigo.ie/~pjn
23rd June 1999