Is there a way thru VB to determine whether or not the program is running on a Win NT machine or Win 2000 machine?
Printable View
Is there a way thru VB to determine whether or not the program is running on a Win NT machine or Win 2000 machine?
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. :D They get really ticked when that is pointed out. :D Notice the platform Id has not changed since NT 3.51! Try thisVB 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
Thanks, I will give it a try.
That worked great!. It was just what I needed.
Thanks...
:D
What about Xp? :p
hmmm ... seems you say that more often than me now :DQuote:
Originally posted by Hack
:D
Quote:
Originally posted by James Stanich
What about Xp? :p
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
hmmmm .... What about Terminal Server :p
And Citrix Server ?
hmm... seems we have to make some addons to these routines :)
It'll work for most OS's. Just trying to give Hack a hard time...;) :pQuote:
Originally posted by peet
hmm... seems we have to make some addons to these routines :)
:)Quote:
Originally posted by James Stanich
It'll work for most OS's. Just trying to give Hack a hard time...;) :p
I would really like to detirmine if my app was running on a Terminal Server, so hopefully hack will dig into that pile of old VBP-Journals that he has in his basement, and deliver a solution before I get out of bed tomorrow morning :)
night all :)
I got the solution from someone on these board a long time ago.
I found the thread, but it looks like I am talking to myself :eek:
here take a look James : http://www.vbforums.com/showthread.p...erminal+server
weird :)
So where's the RyeBread code?
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...:(
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 :rolleyes:
VB Code:
If Left$(Environ$("SESSIONNAME"), 3) = "RDP" Then MsgBox "TS Detected!!" End If
just in case anyone else wanted this :)
Nice one peet, it'll come in handy.
glad you liked it :)
now we just need someone with access to citrix to figure out if Left(Environ$("SESSIONNAME"), 3) = "RDP" is true or not :)