ACC: How to Determine Windows and MS-DOS Versions

Last reviewed: June 8, 1997
Article ID: Q109723
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

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 PgmApi
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.