|
-
Aug 10th, 2004, 10:21 AM
#1
Thread Starter
Member
OS determine
I am looking through the search to find out how to detemine the OS.
Basically all I need to do is determine if its win 2000 do something. If win xp do something. I am only going to be installing this program on 2000 or xp only.
Rob
-
Aug 10th, 2004, 10:28 AM
#2
Need-a-life Member
VB Code:
Option Explicit
Private 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
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Function GetVersion() As String
Dim os As OSVERSIONINFO
os.dwOSVersionInfoSize = Len(os)
GetVersion = "N/A"
If GetVersionEx(os) Then
'VER_PLATFORM_WIN32s
' Win32s on Windows 3.1.
'VER_PLATFORM_WIN32_WINDOWS
' Windows 95
' Windows 98
' Windows Me.
'VER_PLATFORM_WIN32_NT
' Windows NT 3.51
' Windows NT 4.0
' Windows 2000
' Windows XP
' Windows .NET Server
If os.dwPlatformID = VER_PLATFORM_WIN32_NT Then
' Windows NT 3.51 3
' Windows NT 4.0 4
' Windows 2000 5
' Windows XP 5
' Windows .NET Server 5
If os.dwMajorVersion = 3 Then
GetVersion = "Microsoft Windows NT 3.51"
ElseIf os.dwMajorVersion = 4 Then
GetVersion = "Microsoft Windows NT 4"
ElseIf os.dwMajorVersion = 5 Then
' Windows NT 3.51 51
' Windows NT 4.0 0
' Windows 2000 0
' Windows XP 1
' Windows .NET Server 2
Select Case os.dwMinorVersion
Case 0
GetVersion = "Microsoft Windows 2000"
Case 1
GetVersion = "Microsoft Windows XP"
Case 2
GetVersion = "Microsoft Windows .NET Server"
End Select
End If
ElseIf os.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS Then
' Windows 95 4
' Windows 98 4
' Windows Me 4
GetVersion = "Windows 95/98"
If os.dwMajorVersion = 4 Then
' Windows 95 0
' Windows 98 10
' Windows Me 90
Select Case os.dwMinorVersion
Case 0
GetVersion = "Microsoft Windows 95"
Case 10
GetVersion = "Microsoft Windows 98"
Case 90
GetVersion = "Microsoft Windows Me"
End Select
End If
End If
Else
GetVersion = "N/A"
End If
End Function
Private Sub Form_Load()
Debug.Print GetVersion
End Sub
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Aug 10th, 2004, 10:33 AM
#3
VB Code:
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef 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
-
Aug 10th, 2004, 10:38 AM
#4
Thread Starter
Member
I am working on the code will let ui know what happens
Last edited by PartyInaCan; Aug 10th, 2004 at 10:43 AM.
-
Aug 10th, 2004, 12:10 PM
#5
Thread Starter
Member
yes this worked fine. My question is did you write this code or did u just figure it out. I am just curious to know.
Rob
-
Aug 10th, 2004, 01:07 PM
#6
Need-a-life Member
Originally posted by PartyInaCan
yes this worked fine. My question is did you write this code or did u just figure it out. I am just curious to know.
Rob
I've downloaded it from one or more sites.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
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
|