- dwMajorVersion which gives info about the major version of the OS .This value is 3 for win Nt 3.51, 4 for win95/98/me and win nt4 and it is 5 for win2k.
- dwMinorVersion ,another parameter to differentiate the OS further .It is 0 for win 95,10 for win 98 ,98 for win ME,0 for win2k ,0 for win nt4 and 51 for win nt 3.51
- dwPlatformId .This is an important parameter which helps in further differentiating the varios win OS.It is 1 for win 95/ 98/ME ,and 2 for win NT
Get Operating System Version
The Api used for this are
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 ' Maintenance string for PSS usage
The GetVersion Api just takes one parameter of type OSVERSIONINFO. The OSVERSIONINFO structure will contain all the details about the OS after GetVersionApi has been successfully executed. The parameters of OSVERSIONINFO are
Once Declared we can use this in the following way
Dim os As OSVERSIONINFO
os.dwOSVersionInfoSize = Len(os) 'Assign some size to store the received information
Dim m As Long
Dim mv As Long
Dim pd As Long
Dim miv As Long
m = GetVersionEx(os) 'The actual API call to GetVersionEx
mv = os.dwMajorVersion
pd = os.dwPlatformId
miv = os.dwMinorVersion
If pd = 2 Then MsgBox " OS is Windows NT" & mv & "." & miv
If pd = 1 Then
If miv = 10 Then MsgBox " OS is Windows 98 "
If miv = 0 Then MsgBox " OS is Windows 95 "
If miv = 90 Then MsgBox " OS is Windows ME "
This can be quite useful if you are making OS specific Applications.