There are many classes to get Windows version numbers, so why another one? Briefly, because none of them offered the simplicity and low overhead that I wanted, while giving me the information I needed. Instead of writing endless standalone functions (is it XP? is it SP2?), I decided to incorporate everything into a single class.
To keep the class overhead down to a minimum, I designed a new class as a singleton, with version data retrieved and stored only once per program.
CXWinVersion class includes functions to retrieve the OS version number both as an integer and a string value, as well as service pack.
Here are the functions available in
How To Use
To integrate XWinVer into your app, you first need to add XWinVer.h and XWinVer.cpp to your project. Next, include the header file XWinVer.h in each source module that you want to use
CXWinVersion in. Now you can call
CXWinVersion functions by just writing:
BOOL bXPSP2 = WinVersion.IsXPSP2();
WinVersion is automatically instantiated when you include the header file XWinVer.h.
The Demo App
The demo app displays various version info:
For Windows XP:
For Windows Vista:
Version 1.2 - 2007 June 7
- Added IsVista(), IsVistaXXXXX()
- Added GetVistaProductString()
- Added GetVistaProductType()
- Added GetPlatformId()
- Added IsMediaCenter()
- Added IsWin95()
- Added IsWin98()
- Added IsWinCE()
Version 1.1 - 2005 March 14
This software is released into the public domain. You are free to use it in any way you like, except that you may not sell this source code. If you modify it or extend it, please do consider posting the new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.