home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch16code / version.bas < prev    next >
Encoding:
BASIC Source File  |  1995-08-14  |  1.9 KB  |  62 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3. #If Win16 Then
  4. Declare Function GetVersion Lib "Kernel" () _
  5.     As Long
  6. #Else
  7. Declare Function GetVersion Lib "Kernel32" () _
  8.     As Long
  9. #End If
  10.  
  11. ' Demonstrates how to get windows verion information
  12. ' without using the SysInfo custom control.
  13. Sub main()
  14.     Dim lWinInfo As Long, strWinVer As String, strDosVersion As String
  15.     ' Debugging statements to test HiWord, LoWord, HiByte, LoByte.
  16.     #Const DebugBuild = 0
  17.     #If DebugBuild Then
  18.         Dim Temp
  19.         Temp = &HFEEDBABE
  20.         Debug.Print Hex(HiByte(HiWord(Temp))) & _
  21.             Hex(LoByte(HiWord(Temp))) & _
  22.             Hex(HiByte(LoWord(Temp))) & _
  23.             Hex(LoByte(LoWord(Temp)))
  24.     #End If
  25.     ' Retrieve Windows version information.
  26.     lWinInfo = GetVersion()
  27.     ' Parse the Windows version number from the returned
  28.     ' Long integer value.
  29.     Dim x
  30.     strWinVer = LoByte(LoWord(lWinInfo)) & "." & HiByte(LoWord(lWinInfo))
  31.     ' Parse the DOS version number from the returned
  32.     ' Long integer value (shown here for informational purposes -- not used).
  33.     ' strDosVersion = HiByte(HiWord(lWinInfo)) & "." & LoByte(HiWord(lWinInfo))
  34.     '
  35.     ' If the version is less than 3.5 (Win NT 3.5)...
  36.     If Val(strWinVer) < 3.5 Then
  37.         Shell "Setup1.EXE"      ' Run the 16-bit setup.
  38.     Else                        ' Otherwise,
  39.         Shell "Setup132.EXE"    ' run the 32-bit setup.
  40.     End If
  41. End Sub
  42.  
  43. Function LoWord(lArg)
  44.     LoWord = lArg And (lArg Xor &HFFFF0000)
  45. End Function
  46.  
  47. Function HiWord(lArg)
  48.     If lArg > &H7FFFFFFF Then
  49.         HiWord = (lArg And &HFFFF0000) \ &H10000
  50.     Else
  51.         HiWord = ((lArg And &HFFFF0000) \ &H10000) Xor &HFFFF0000
  52.     End If
  53. End Function
  54.  
  55. Function HiByte(iArg)
  56.     HiByte = (iArg And &HFF00) \ &H100
  57. End Function
  58.  
  59. Function LoByte(iArg)
  60.     LoByte = iArg Xor (iArg And &HFF00)
  61. End Function
  62.