Function fOSName() As String
Dim osvi As OSVERSIONINFO
Dim strOut As String
osvi.dwOSVersionInfoSize = Len(osvi)
If CBool(apiGetVersionEx(osvi)) Then
With osvi
If .dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion = 5 Then
Select Case .dwMinorVersion
Case 0
strOut = "Windows 2000 " & _
.dwMajorVersion & "." & .dwMinorVersion & _
" Build " & .dwBuildNumber
Case 1
strOut = "Windows XP"
End Select
End If
If .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
Select Case .dwMinorVersion
Case 0
strOut = "Windows 95"
Case 90
strOut = "Windows ME"
Case Else
strOut = "Windows 98"
End Select
End If
If (.dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion <= 4) Then
strOut = "Windows NT " & _
.dwMajorVersion & "." & .dwMinorVersion & _
" Build " & .dwBuildNumber
End If
End With
End If
fOSName = strOut
End Function Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
1. This came from my 'useful bits of code collection' credit should go to the author, but I do not know who he/she is
2. Missed a bit ot at the beginning
Option Compare Database
Option Explicit
' ********** Code Start **********
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function apiGetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As Any) _
As Long
Function fOSName() As String
Dim osvi As OSVERSIONINFO
Dim strOut As String
osvi.dwOSVersionInfoSize = Len(osvi)
If CBool(apiGetVersionEx(osvi)) Then
With osvi
If .dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion = 5 Then
Select Case .dwMinorVersion
Case 0
strOut = "Windows 2000 " & _
.dwMajorVersion & "." & .dwMinorVersion & _
" Build " & .dwBuildNumber
Case 1
strOut = "Windows XP"
End Select
End If
If .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
Select Case .dwMinorVersion
Case 0
strOut = "Windows 95"
Case 90
strOut = "Windows ME"
Case Else
strOut = "Windows 98"
End Select
End If
If (.dwPlatformId = VER_PLATFORM_WIN32_NT And _
.dwMajorVersion <= 4) Then
strOut = "Windows NT " & _
.dwMajorVersion & "." & .dwMinorVersion & _
" Build " & .dwBuildNumber
End If
End With
End If
fOSName = strOut
End Function
Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.