ACC2000: Sample Function to Determine Windows 95/98 or NT Version

ID: Q210200


The information in this article applies to:
  • Microsoft Access 2000


SUMMARY

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

This article describes how you can use the GetVersionEx() Windows API function to determine the version number of the operating system (Microsoft Windows NT or Windows 95/98) running on the computer.


MORE INFORMATION

Although the GetVersion() function is still supported under Win32, it has been superseded by GetVersionEx(), which identifies Windows 95/98, returns more accurate information about the build of Windows, and no longer returns the version of MS-DOS.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The following example function demonstrates how to use the GetVersionEx() Windows API function:
  1. Create a module and type the following code in the Declarations section:
    
    '====================================
    ' Global Declarations
    '====================================
    
    Option Explicit
    
    Type OSVERSIONINFO
       dwOSVersionInfoSize As Long
       dwMajorVersion As Long
       dwMinorVersion As Long
       dwBuildNumber As Long
       dwPlatformId As Long
       szCSDVersion As String * 128   ' Maintenance string for PSS usage.
    End Type
    
    Public Const VER_PLATFORM_WIN32s = 0
    Public Const VER_PLATFORM_WIN32_WINDOWS = 1
    Public Const VER_PLATFORM_WIN32_NT = 2
    
    Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
      (lpVersionInformation As OSVERSIONINFO) As Long 



  2. Type the following procedure:
    
    Function SysVersions32()
    
       Dim v As OSVERSIONINFO, retval As Long
       Dim WindowsVersion As String, BuildVersion As String
       Dim PlatformName As String
    
       v.dwOSVersionInfoSize = Len(v)
       retval = GetVersionEx(v)
    
       WindowsVersion = v.dwMajorVersion & "." & v.dwMinorVersion
       BuildVersion = v.dwBuildNumber And &HFFFF&
    
       Select Case v.dwPlatformId
          Case VER_PLATFORM_WIN32_WINDOWS
             PlatformName = "Windows 95/98"
          Case VER_PLATFORM_WIN32_NT
             PlatformName = "Windows NT"
       End Select
    
       MsgBox "Platform: " & PlatformName & vbCrLf & _
          "Version: " & WindowsVersion & vbCrLf & _
          "Build: " & BuildVersion
    
    End Function 


  3. To test this function, type the following line in the Immediate window, and then press ENTER:
    
    ?SysVersions32() 
    Note that the message box displays the operating system's name, version, and build number.


The GetVersionEx() function fills the OSVERSIONINFO structure, which contains elements for the operating system platform, version, and build information. Note that the element dwPlatformId could be any of the VER_PLATFORM_ constants listed at the top of the example.

Additional query words: Win95 Win98 WinNT

Keywords : kbprg kbdta AccCon KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.