Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

DtWinVer v1.34 - OS Detection Utility

0.00/5 (No votes)
3 Mar 2000 2  
A comprehensive OS detection utility.
  • Download source files - 58 Kb
  • Features
    History
    API Reference
    Notes
    Enhancements
    Contacting the Author


    Features

    DtWinVer 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 aswell as the underlying OS. e.g. to a Dos program Windows 95 looks like MS-DOS 7.0. A full list of the OS versions 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 Service Pack 1
    • 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
    • Windows NT Enterprise Edition

    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 (23 June 1999)

    • 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 Servers.
    • Added explicit support for NT Stand Alone Servers.
    • Added explicit support for NT Primary Domain Controllers.
    • Added explicit support for NT Backup Domain Controllers.

    V1.31 (23 July 1999)

    • Tested out support for Windows 98 SE, minor changes required.

    V1.32 (26 July 1999)

    • Added explicit support for Windows 98 SP 1.

    V1.33 (28 July 1999)

    • Fixed a problem when application is build in non-huge/large memory model in Win16.
    • Added explicit support for returning NT and Win9x service pack information from Win32 and Win16 code paths.
    • Updated test program to not bother reporting on any info which does not exist. e.g. if there is no service pack installed, then we don't bother displaying any info about service packs.
    • Added explicit support for NT Enterprise Edition.

    V1.34 (2 February 2000)

    • Fixed a minor copy and paste bug in the test program.


    API

    GetOSVersion

    BOOL GetOSVersion(LPOS_VERSION_INFO lpVersionInformation);

    Return Value:
    TRUE if the function was successful otherwise FALSE.

    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
         WORD wEmulatedServicePack;
      
         //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
         WORD wUnderlyingServicePack;
      } OS_VERSION_INFO, *POS_VERSION_INFO, FAR *LPOS_VERSION_INFO;
      

      This will be filled in upon a successful return from the function.

    Remarks:
    Internally this function is called when you click on the "..." button on the UI. You are free to use this independently of the DDX / DDV code to call up a directory picker dialog in your own code.



    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 / workspace 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://www.naughter.com
    2 February 2000


    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here