ACC: How to Determine Windows and MS-DOS Versions

ID: Q109723


The information in this article applies to:


SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article describes how you can use the GetVersion() Windows API function to return the version numbers of Microsoft Windows and MS-DOS running on the computer.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access Basic" in version 2.0.


MORE INFORMATION

The following example demonstrates how to use the GetVersion() Windows API function in the KERNEL.EXE dynamic link library (DLL) included with Windows:

NOTE: In the following sample code, an underscore (_) is used as a line- continuation character. Remove the underscore when re-creating this code in Access Basic.


   '====================================
   ' Global Declarations
   '====================================
   Option Explicit

   Declare Function GetVersion Lib "Kernel" () As Long

   Function SysVersions ()
      Dim ver As Long, WinVer As Long, DosVer As Long
      Dim WindowsVersion As String, DosVersion As String

      ver = GetVersion()

      WinVer = ver And &HFFF&
      WindowsVersion = Format((WinVer Mod 256) + _
         ((WinVer \ 256) / 100), "Fixed")

      DosVer = ver \ &H10000
      DosVersion = Format((DosVer \ 256) + _
         ((DosVer Mod 256) / 100), "Fixed")

      MsgBox "Windows Version: " & WindowsVersion _
         & Chr(13) & "DOS Version: " & DosVersion

   End Function 

The GetVersion() function returns a value that is a DWORD (double word), which translates into a long integer (32-bit value) in Access Basic. The low-order word returns the major (low byte) and minor (high byte) Windows version number, and the high-order word returns the major (high byte) and minor (low byte) MS-DOS version number.


REFERENCES

Microsoft Windows Software Development Kit "Programmer's Reference Volume 2: Functions," pages 469-470


Keywords          : kbprg 
Version           : 1.0 1.1 2.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: April 1, 1999