Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i detect windows version?

Status
Not open for further replies.
Mar 25, 2003
34
GB
...as well as resolution etc from vba?
 
You'll need to use the API. There should be some threads in this forum that show how to do both of these; here's the Windows version code again. Declare the API function and OS structure in a module:
Code:
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
  (lpVersionInformation As OSVERSIONINFO) As Long

Public Type OSVERSIONINFO
   dwOSVersionInfoSize As Long
   dwMajorVersion As Long
   dwMinorVersion As Long
   dwBuildNumber As Long
   dwPlatformId As Long
   szCSDVersion As String * 128
End Type
Add the wrapper function to convert the result to a string:
Code:
Public Function GetWindowsVersion() As String
' Purpose: Find Windows version

On Error GoTo ErrHandler
  Dim strOSName As String
  Dim OSInfo As OSVERSIONINFO
   
  OSInfo.dwOSVersionInfoSize = 148
  OSInfo.szCSDVersion = Space$(128)
  
  ' API call to get operating system info.
  Call GetVersionEx(OSInfo)
  
  With OSInfo
    Select Case .dwPlatformId
      Case 1
        Select Case .dwMinorVersion
          Case 0
            strOSName = "Windows 95"
          Case 10
            strOSName = "Windows 98"
          Case 90
            strOSName = "Windows Millennium"
        End Select
      Case 2
        Select Case .dwMajorVersion
          Case 3
            strOSName = "Windows NT 3.51"
          Case 4
            strOSName = "Windows NT 4.0"
          Case 5
          If .dwMinorVersion = 0 Then
            strOSName = "Windows 2000"
          Else
            strOSName = "Windows XP"
          End If
        End Select
      Case Else
          strOSName = "Failed"
    End Select
  End With

  GetWindowsVersion = strOSName

ExitHere:
  Exit Function
ErrHandler:
  Debug.Print Err, Err.Description
  Resume ExitHere
End Function
There is a class module developed by Ken Getz, et al that will do all the screen coordinate info, which you can use if you buy the book "Access 2000 Developer's Handbook"

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top