|
-
Feb 3rd, 2003, 09:52 PM
#1
Thread Starter
Hyperactive Member
Everyone please read this
This code is from API-Guide
Code:
Private Declare Function GetVersion Lib "kernel32" () As Long
Public Function GetWinVersion() As String
Dim Ver As Long, WinVer As Long
Ver = GetVersion()
WinVer = Ver And &HFFFF&
'retrieve the windows version
GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
End Function
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
MsgBox "Windows version: " + GetWinVersion
End Sub
Problem is, what number does it return on the following OSes:
Windows 95 =
Windows 95 w/USB support =
Windows 98 =
Windows 98 SE =
Windows ME =
Windows NT =
Windows 2k =
Windows XP = 5.01 (what mine returned, is it same for home and pro?)
If somebody runs any version shown above, can you please run the code and post a reply with your windows version and the number it gave. If i missed any windows version, sorry about that, but I don't think I did.
-
Feb 3rd, 2003, 10:12 PM
#2
Frenzied Member
-
Feb 3rd, 2003, 10:15 PM
#3
-
Feb 3rd, 2003, 10:18 PM
#4
PowerPoster
Well
VB Code:
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
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 Sub Form_Load()
Dim OSInfo As OSVERSIONINFO, PId As String
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Set the structure size
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
'Get the Windows version
Ret& = GetVersionEx(OSInfo)
'Chack for errors
If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
'Print the information to the form
Select Case OSInfo.dwPlatformId
Case 0
PId = "Windows 32s "
Case 1
PId = "Windows 95/98"
Case 2
PId = "Windows NT "
End Select
Print "OS: " + PId
Print "Win version:" + str$(OSInfo.dwMajorVersion) + "." + LTrim(str(OSInfo.dwMinorVersion))
Print "Build: " + str(OSInfo.dwBuildNumber)
End Sub
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Feb 3rd, 2003, 11:35 PM
#5
Thread Starter
Hyperactive Member
Oh that sucks, so Win95 and Win98 are the same number? That's the main reason I need this, to distinguish between Win95 and all others. Is there any other way to see if computer is running Windows 95 (it's for CreateWaitableTimer API, which only works on Windows 98 and later).
-
Feb 3rd, 2003, 11:42 PM
#6
Thread Starter
Hyperactive Member
-
Feb 4th, 2003, 12:03 AM
#7
Frenzied Member
Getting the System Version
That article ought to help you out a little more. Shows how to distinguish a lot more.
-
Feb 4th, 2003, 12:13 AM
#8
Thread Starter
Hyperactive Member
Can someone test this out for me on Windows 95, 98, ME and 2k. Let me know if it works, it should. I just converted this from MSDN article and cutted out some detailed info parts. I just need basic version info.
Code:
Option Explicit
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 ' Maintenance string for PSS usage
End Type
Const VER_PLATFORM_WIN32s = 0
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32_NT = 2
Public Function GetWindowsVersion() As String
Dim ret As String
Dim osvi As OSVERSIONINFO
osvi.dwOSVersionInfoSize = Len(osvi)
If Not GetVersionEx(osvi) Then ret = "GetWindowsVersion Failed"
Select Case osvi.dwPlatformId
Case VER_PLATFORM_WIN32_NT:
If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 2 Then ret = "Microsoft Windows, Windows Server 2003, 2003 family"
If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 1 Then ret = "Microsoft Windows XP"
If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 0 Then ret = "Microsoft Windows 2000"
If osvi.dwMajorVersion <= 4 Then ret = "Microsoft Windows NT"
Case VER_PLATFORM_WIN32_WINDOWS:
If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 0 Then ret = "Microsoft Windows 95"
If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 10 Then ret = "Microsoft Windows 98"
If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 90 Then ret = "Microsoft Windows Millennium Edition"
Case VER_PLATFORM_WIN32s:
ret = "Microsoft Win32s"
End Select
GetWindowsVersion = ret
End Function
call it with msgbox GetWindowsVersion
Thanks a lot!
Last edited by Dmitri K; Feb 4th, 2003 at 12:18 AM.
-
Feb 4th, 2003, 12:30 AM
#9
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|