Solved

How to determine which operating system

Posted on 1998-12-03
2
346 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
ID: 1448018
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
ID: 1448019
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

791 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