Solved

How to determine which operating system

Posted on 1998-12-03
2
342 Views
Last Modified: 2012-06-21
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
Comment
Question by:johnnymccarthy
2 Comments
 
LVL 14

Expert Comment

by:waty
Comment Utility
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
 
LVL 12

Accepted Solution

by:
mark2150 earned 50 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now