ACC: How to Determine Windows and MS-DOS VersionsID: Q109723
|
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.
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
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