Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

How to determine which operating system

I need to determine which operating system my application is running on. It is a 16bit app so could run on Windows 3.1, 3.11, 95, 98 or NT.
0
johnnymccarthy
Asked:
johnnymccarthy
1 Solution
 
watyCommented:
Here is under 32 bits.

' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 7/10/98
' * Time             : 14:39
' * Module Name      : System_Information_Module
' * Module Filename  :
' **********************************************************************
' * Comments         : Get some system information
' *
' *
' **********************************************************************

Option Explicit

' *** System Parameters Information Constants, Types and Declares
Public Const SPI_GETBEEP = 1
Public Const SPI_GETANIMATION = 72
Public Const SPI_GETBORDER = 5
Public Const SPI_GETDEFAULTINPUTLANG = 89
Public Const SPI_GETFONTSMOOTHING = 74
Public Const SPI_GETGRIDGRANULARITY = 18
Public Const SPI_GETICONTITLEWRAP = 25
Public Const SPI_GETKEYBOARDDELAY = 22
Public Const SPI_GETKEYBOARDSPEED = 10
Public Const SPI_GETKEYBOARDPREF = 68
Public Const SPI_GETMENUDROPALIGNMENT = 27
Public Const SPI_GETMOUSETRAILS = 94
Public Const SPI_GETSCREENREADER = 70
Public Const SPI_GETSCREENSAVEACTIVE = 16
Public Const SPI_GETSCREENSAVETIMEOUT = 14
Public Const SPI_GETSHOWSOUNDS = 56
Public Const SPI_GETWINDOWSEXTENSION = 92
Public Const SPI_GETWORKAREA = 48

Type ANIMATIONINFO
   cbSize As Long
   iMinAnimate As Long
End Type

Type RECT
   Left   As Long
   Top    As Long
   Right  As Long
   Bottom As Long
End Type

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

' *** Operating System Constants, Types and Declares
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2

Type OSVERSIONINFO
   dwOSVersionInfoSize As Long
   dwMajorVersion      As Long
   dwMinorVersion      As Long
   dwBuildNumber       As Long
   dwPlatformId        As Long
   szCSDVersion        As String * 128
End Type

Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Sub GetSystemInformation()
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 7/10/98
   ' * Time             : 14:40
   ' * Module Name      : System_Information_Module
   ' * Module Filename  :
   ' * Procedure Name   : GetSystemInformation
   ' * Parameters       :
   ' **********************************************************************
   ' * Comments         : Get some system information
   ' *
   ' *
   ' **********************************************************************

   Dim OSInfo     As OSVERSIONINFO
   
   Dim sWindows   As String
   
   ' *** Operating System Information
   On Error Resume Next
   OSInfo.dwOSVersionInfoSize = Len(OSInfo)
   Call GetVersionEx(OSInfo)
   With OSInfo
      ' *** .dwMajorVersion
      ' *** .dwMinorVersion
      ' *** .dwPlatformId
      ' *** Trim$(.szCSDVersion)
      ' *** .dwBuildNumber
   End With

   Select Case OSInfo.dwPlatformId
      Case VER_PLATFORM_WIN32_NT
         sWindows = "NT"
      Case VER_PLATFORM_WIN32_WINDOWS
         sWindows = "Windows"
      Case VER_PLATFORM_WIN32s
         sWindows = "Windows 3.1"
   End Select
   
   ' *** System Parameters Information
   Dim iValue   As Integer
   Dim lValue   As Long
   Dim bBool    As Boolean
   Dim tRect    As RECT
   Dim tAnimate As ANIMATIONINFO
   
   ' *** Indicate whether the warning Beeper is on.
   Call SystemParametersInfo(SPI_GETBEEP, vbNull, bBool, 0)
   
   ' *** Get the border multiplier factor that determines the
   ' *** width of a windows sizing border.
   Call SystemParametersInfo(SPI_GETBORDER, vbNull, iValue, 0)
   
   ' *** Determine whether the font smoothing feature is enabled.
   ' *** This feature uses font anti-aliasing to make font curves
   ' *** appear smoother by painting pixels at different gray levels.
   Call SystemParametersInfo(SPI_GETFONTSMOOTHING, vbNull, bBool, 0)
   
   ' *** Get the current granularity value of the desktop sizing grid.
   Call SystemParametersInfo(SPI_GETGRIDGRANULARITY, vbNull, iValue, 0)
   
   ' *** Determine whether icon-title wrapping is enabled.
   Call SystemParametersInfo(SPI_GETICONTITLEWRAP, vbNull, bBool, 0)
   
   ' *** Determine whether pop-up menus are left-aligned or
   ' *** right-aligned, relative to the corresponding menu-bar item.
   Call SystemParametersInfo(SPI_GETMENUDROPALIGNMENT, vbNull, bBool, 0)
   If bBool Then
      ' *** "Left"
   Else
      ' *** "Right"
   End If
   
   ' *** Determine whether screen saving is enabled.
   Call SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, vbNull, bBool, 0)
   
   ' *** Retrieve the screen saver time-out value, in seconds.
   Call SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, vbNull, iValue, 0)
   
   ' *** Determine if the Show Sounds accessibility flag is on or
   ' *** off. If it is on, the user requires an application to present
   ' *** information visually in situations where it would otherwise
   ' *** present the information only in audible form.
   Call SystemParametersInfo(SPI_GETSHOWSOUNDS, vbNull, bBool, 0)
   
   ' *** See if animation effects are enabled.
   tAnimate.cbSize = Len(tAnimate)
   Call SystemParametersInfo(SPI_GETANIMATION, vbNull, tAnimate, 0)
   ' *** (tAnimate.iMinAnimate > 0)
   
   ' *** Retrieve the keyboard repeat-delay setting.
   Call SystemParametersInfo(SPI_GETKEYBOARDDELAY, vbNull, iValue, 0)
   
   ' *** Retrieve the keyboard repeat-speed setting.
   Call SystemParametersInfo(SPI_GETKEYBOARDSPEED, vbNull, lValue, 0)
   
   ' *** Get the keyboard layout handle for the system default input language.
   Call SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, vbNull, lValue, 0)
   
   ' *** Determine if the user relies on the keyboard instead of the mouse,
   ' *** and wants applications to display keyboard interfaces that would
   ' *** otherwise be hidden.
   Call SystemParametersInfo(SPI_GETKEYBOARDPREF, vbNull, bBool, 0)
   
   ' *** Retrieve the screen's working area size (i.e. the portion of
   ' *** the screen not obscured by the taskbar or other appbars).
   Call SystemParametersInfo(SPI_GETWORKAREA, vbNull, tRect, 0)
   
   ' *** WINDOWS 9x ONLY.
   If sWindows = "Windows" Then
     
      ' *** Indicate if the Mouse Trails feature is enabled. This feature
      ' *** improves the visibility of mouse cursor movements by briefly
      ' *** showing a trail of cursors and quickly erasing them.
      Call SystemParametersInfo(SPI_GETMOUSETRAILS, vbNull, iValue, 0)
      ' *** (iValue > 1)
     
      ' *** Determine of a screen reviewer utility is running. A screen
      ' *** reviewer utility directs textual information to an output device,
      ' *** such as a speech synthesizer or Braille display. When this flag
      ' *** is set, an application should provide textual information in
      ' *** situations where it would otherwise present the information
      ' *** graphically.
      Call SystemParametersInfo(SPI_GETSCREENREADER, vbNull, bBool, 0)
     
      ' *** Indicate whether the Windows extension, Windows Plus!, is installed.
      bBool = SystemParametersInfo(SPI_GETWINDOWSEXTENSION, 1, 0, 0)
   End If
   
End Sub

0
 
mark2150Commented:
SHELL( ENVIRON("COMSPEC") & "COMMAND.COM /C VER > C:\X", 1)
OPEN "C:\X" FOR INPUT AS #1
LINE INPUT #1 VERSIONINFO
CLOSE


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now