|
-
Oct 18th, 2002, 02:16 PM
#1
Thread Starter
Addicted Member
Determining operating system
Is there a way thru VB to determine whether or not the program is running on a Win NT machine or Win 2000 machine?
-
Oct 18th, 2002, 02:21 PM
#2
Win2000 is NT - it is nothing more than NT5 with a fancier name. In fact, it started out life as NT5, and then Microsoft decided that the name needed some work. They get really ticked when that is pointed out. Notice the platform Id has not changed since NT 3.51! Try this
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
Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
Private Function LoWord(lngIn As Long) As Integer
If (lngIn And &HFFFF&) > &H7FFF Then
LoWord = (lngIn And &HFFFF&) - &H10000
Else
LoWord = lngIn And &HFFFF&
End If
End Function
Private Function ShowWinVersion(vLabel As Label)
Dim version As OSVERSIONINFO
Dim strPlatform As String
version.dwOSVersionInfoSize = Len(version)
GetVersionEx version
If version.dwPlatformId = 1 And version.dwMinorVersion = 10 And LoWord(version.dwBuildNumber) = 1998 Then
strPlatform = "Microsoft Windows 98 "
ElseIf version.dwPlatformId = 1 And version.dwMinorVersion = 10 And LoWord(version.dwBuildNumber) = 2222 Then
strPlatform = "Microsoft Windows 98 SE "
ElseIf version.dwPlatformId = 1 And version.dwMinorVersion = 90 And LoWord(version.dwBuildNumber) = 3000 Then
strPlatform = "Microsoft Windows ME "
ElseIf version.dwPlatformId = 1 And version.dwMinorVersion = 0 And LoWord(version.dwBuildNumber) = 950 Then
strPlatform = "Microsoft Windows 95 "
ElseIf version.dwPlatformId = 1 And version.dwMinorVersion = 0 And LoWord(version.dwBuildNumber) = 1111 Then
strPlatform = "Microsoft Windows 95B "
End If
If version.dwPlatformId = 2 And version.dwMajorVersion = 3 Then
strPlatform = "Microsoft Windows NT 3.51 "
ElseIf version.dwPlatformId = 2 And version.dwMajorVersion = 4 Then
strPlatform = "Microsoft Windows NT "
ElseIf version.dwPlatformId = 2 And version.dwMajorVersion = 5 Then
strPlatform = "Microsoft Windows 2000 "
End If
strPlatform = strPlatform & "v" & Format(version.dwMajorVersion) & "." & _
Format(version.dwMinorVersion) & " (Build " & LoWord(version.dwBuildNumber) & ")"
vLabel.Alignment = 2
vLabel.BackStyle = 0
vLabel.Caption = strPlatform
End Function
Private Sub Form_Load()
'Developed by amitabh
ShowWinVersion Label1
End Sub
-
Oct 18th, 2002, 02:23 PM
#3
Thread Starter
Addicted Member
Thanks, I will give it a try.
-
Oct 18th, 2002, 02:37 PM
#4
Thread Starter
Addicted Member
That worked great!. It was just what I needed.
Thanks...
-
Oct 18th, 2002, 02:37 PM
#5
As peet is fond of saying...
-
Oct 18th, 2002, 04:03 PM
#6
PowerPoster
Well
What about Xp?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 18th, 2002, 04:11 PM
#7
-= B u g S l a y e r =-
Re: As peet is fond of saying...
Originally posted by Hack
hmmm ... seems you say that more often than me now
-
Oct 18th, 2002, 04:12 PM
#8
-= B u g S l a y e r =-
Re: Well
Originally posted by James Stanich
What about Xp?
VB Code:
Public Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Public Function getVersion() As String
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
With osinfo
Select Case .dwPlatformId
Case 1
Select Case .dwMinorVersion
Case 0
getVersion = "Windows 95"
Case 10
getVersion = "Windows 98"
Case 90
getVersion = "Windows Mellinnium"
End Select
Case 2
Select Case .dwMajorVersion
Case 3
getVersion = "Windows NT 3.51"
Case 4
getVersion = "Windows NT 4.0"
Case 5
If .dwMinorVersion = 0 Then
getVersion = "Windows 2000"
Else
getVersion = "Windows XP"
End If
End Select
Case Else
getVersion = "Failed"
End Select
End With
End Function
-
Oct 18th, 2002, 04:13 PM
#9
-= B u g S l a y e r =-
hmmmm .... What about Terminal Server
-
Oct 18th, 2002, 04:13 PM
#10
PowerPoster
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 18th, 2002, 04:14 PM
#11
-= B u g S l a y e r =-
hmm... seems we have to make some addons to these routines
-
Oct 18th, 2002, 04:15 PM
#12
PowerPoster
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 18th, 2002, 04:20 PM
#13
-= B u g S l a y e r =-
-
Oct 18th, 2002, 04:24 PM
#14
-
Oct 18th, 2002, 04:28 PM
#15
PowerPoster
Well
So where's the RyeBread code?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 18th, 2002, 04:31 PM
#16
PowerPoster
Well
Determining the system OS with the SysInfo control
VB Code:
Dim OS As String
With SysInfo1
Select Case .OSPlatform
Case 0: OS = "Win32"
Case 1:
Select Case .OSVersion
Case 4: OS = "Win 95"
Case 4.1: OS = "Win 98"
End Select
Case 2:
Select Case .OSVersion
Case 4: OS = "Win NT"
Case 5: OS = "Win 2000"
Case 6: OS = "Win XP"
End Select
End Select
MsgBox "Build:" & .OSBuild & vbNewLine & _
"Platform:" & OS & "(" & .OSPlatform & ")" & vbNewLine & _
"Version:" & .OSVersion
End With
Still no terminal server though...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 18th, 2002, 05:03 PM
#17
-= B u g S l a y e r =-
TS is not an OS, thus it will not work this way, I think his answer had something to do with reading an environment setting, and from that you could determine if this was a TS or not...just cant remember what environment var to read
Last edited by peet; Oct 19th, 2002 at 02:23 AM.
-
Oct 19th, 2002, 02:23 AM
#18
-= B u g S l a y e r =-
VB Code:
If Left$(Environ$("SESSIONNAME"), 3) = "RDP" Then
MsgBox "TS Detected!!"
End If
just in case anyone else wanted this
-
Oct 19th, 2002, 02:31 AM
#19
Frenzied Member
Nice one peet, it'll come in handy.
-
Oct 19th, 2002, 02:37 AM
#20
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
|