thimerion
asked on
Retrieve windows version in VB
Hi all,
is there a statement in VB to get the windows version your are working with as result?
Tim
is there a statement in VB to get the windows version your are working with as result?
Tim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
If I may make a comment on the use of GetVersionEX api... Using that method for detecting the operating system version is kind of buggy. In your if statement you only assume two platforms, namely '95 and NT.
Check the value's in dwMinorVersion and dwMajorVersion against the following table:
dwMajorVersion:
Identifies the major version number of the operating system as follows.
Windows95:= 4
Windows98:= 4
WindowsME:= 4
Windows NT 3.51:= 3
Windows NT 4.0:= 4
Windows 2000:= 5
Windows XP:= 5
Windows .Net Server:= 5
dwMinorVersion:
Identifies the minor version number of the operating system as follows:
Windows95:= 0
Windows98:= 10
WindowsME:= 90
Windows NT 3.51:= 51
Windows NT 4.0:= 0
Windows 2000:= 0
Windows XP:= 1
Windows .Net Server:= 1
And one last remark on the use of the build number in your code:
dwBuildNumber:
Windows NT/2000/XP: Identifies the build number of the operating system.
Windows 95/98/ME: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers.
Thus, the code can generate unpredictable results on Windows95/98/ME.
No offence intended. I just think you need to specify some more information.
Grtz.©
D.
If I may make a comment on the use of GetVersionEX api... Using that method for detecting the operating system version is kind of buggy. In your if statement you only assume two platforms, namely '95 and NT.
Check the value's in dwMinorVersion and dwMajorVersion against the following table:
dwMajorVersion:
Identifies the major version number of the operating system as follows.
Windows95:= 4
Windows98:= 4
WindowsME:= 4
Windows NT 3.51:= 3
Windows NT 4.0:= 4
Windows 2000:= 5
Windows XP:= 5
Windows .Net Server:= 5
dwMinorVersion:
Identifies the minor version number of the operating system as follows:
Windows95:= 0
Windows98:= 10
WindowsME:= 90
Windows NT 3.51:= 51
Windows NT 4.0:= 0
Windows 2000:= 0
Windows XP:= 1
Windows .Net Server:= 1
And one last remark on the use of the build number in your code:
dwBuildNumber:
Windows NT/2000/XP: Identifies the build number of the operating system.
Windows 95/98/ME: Identifies the build number of the operating system in the low-order word. The high-order word contains the major and minor version numbers.
Thus, the code can generate unpredictable results on Windows95/98/ME.
No offence intended. I just think you need to specify some more information.
Grtz.©
D.
One relatively simply way is:
Add a timer control with enabled=false and interval=200, then add this code
Private Sub Command1_Click()
Shell (Environ("ComSpec") & " /c ver > c:\version.txt")
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim strBlank As String
Dim strVersionText As String
Timer1.Enabled = False
Open "C:\version.txt" For Input As #1
Line Input #1, strBlank
Line Input #1, strVersionText
Close #1
MsgBox strVersionText
Kill "C:\version.txt"
End Sub
Add a timer control with enabled=false and interval=200, then add this code
Private Sub Command1_Click()
Shell (Environ("ComSpec") & " /c ver > c:\version.txt")
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim strBlank As String
Dim strVersionText As String
Timer1.Enabled = False
Open "C:\version.txt" For Input As #1
Line Input #1, strBlank
Line Input #1, strVersionText
Close #1
MsgBox strVersionText
Kill "C:\version.txt"
End Sub
Thimerion,
Are you going to attend to this question?
Grtz.©
D.
Are you going to attend to this question?
Grtz.©
D.
See this:
Handy Routines for Identifying the Windows Version:
http://www.mvps.org/vbnet/index.html?code/helpers/iswinversion.htm
and
Obtaining Windows' Version Information:
http://www.mvps.org/vbnet/code/system/getversionex.htm
Cheers