home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
- #If Win16 Then
- Declare Function GetVersion Lib "Kernel" () _
- As Long
- #Else
- Declare Function GetVersion Lib "Kernel32" () _
- As Long
- #End If
-
- ' Demonstrates how to get windows verion information
- ' without using the SysInfo custom control.
- Sub main()
- Dim lWinInfo As Long, strWinVer As String, strDosVersion As String
- ' Debugging statements to test HiWord, LoWord, HiByte, LoByte.
- #Const DebugBuild = 0
- #If DebugBuild Then
- Dim Temp
- Temp = &HFEEDBABE
- Debug.Print Hex(HiByte(HiWord(Temp))) & _
- Hex(LoByte(HiWord(Temp))) & _
- Hex(HiByte(LoWord(Temp))) & _
- Hex(LoByte(LoWord(Temp)))
- #End If
- ' Retrieve Windows version information.
- lWinInfo = GetVersion()
- ' Parse the Windows version number from the returned
- ' Long integer value.
- Dim x
- strWinVer = LoByte(LoWord(lWinInfo)) & "." & HiByte(LoWord(lWinInfo))
- ' Parse the DOS version number from the returned
- ' Long integer value (shown here for informational purposes -- not used).
- ' strDosVersion = HiByte(HiWord(lWinInfo)) & "." & LoByte(HiWord(lWinInfo))
- '
- ' If the version is less than 3.5 (Win NT 3.5)...
- If Val(strWinVer) < 3.5 Then
- Shell "Setup1.EXE" ' Run the 16-bit setup.
- Else ' Otherwise,
- Shell "Setup132.EXE" ' run the 32-bit setup.
- End If
- End Sub
-
- Function LoWord(lArg)
- LoWord = lArg And (lArg Xor &HFFFF0000)
- End Function
-
- Function HiWord(lArg)
- If lArg > &H7FFFFFFF Then
- HiWord = (lArg And &HFFFF0000) \ &H10000
- Else
- HiWord = ((lArg And &HFFFF0000) \ &H10000) Xor &HFFFF0000
- End If
- End Function
-
- Function HiByte(iArg)
- HiByte = (iArg And &HFF00) \ &H100
- End Function
-
- Function LoByte(iArg)
- LoByte = iArg Xor (iArg And &HFF00)
- End Function
-