Documentation component by John Kelly, Thanks to b_j0@yahoo.com, Rudy Elyn, Chris. QSYSTEM   

QSYSTEM Component

QSYSTEM is a non-visible component in RAPIDQ2.INC. It allows you to open control panels, get information on the Windows operating system and uses WIN32 API calls like GetSystemMetrics, etc.  Most of the properties are really return values from a function that calls the API GetSystemMetrics. Memory return values are in bytes. To get KB divide by 1024 , to get MB divide by 1048576. See limitations.

QSYSTEM Properties





OPERATING SYSTEM
MajorVersion  INTEGER     Returns the Windows major version number R 0
MinorVersion  INTEGER     Returns the Windows minor version number R 0
BuildNumber  INTEGER     Returns the Windows build number R 0
OSname$  STRING        Returns the Name of the Windows operating system  
     (e.g., "Windows 2000")
R 0
 
MEMORY
AvailableMemory DWORD      Returns free RAM memory in bytes. Divide by 1024 to get KB, etc. R 0
PercentFreeMemory DWORD      Returns percent free RAM  as integer in the range 0 - 100 R 0
TotalMemory DWORD      Returns total RAM memory in bytes. Divide by 1024 to get KB, etc. R 0
UsedMemory DWORD      Returns used RAM memory in bytes. Divide by 1024 to get KB, etc. R 0
PageFileMemory DWORD      Returns available page file memory or virtual memory in the system. 
                     Value is  bytes. If this number is below a few MB, you are in trouble.
R 0
AvailableMemory DWORD      Returns free RAM memory in bytes. Divide by 1024 to get KB, etc. R 0
DiskFreeSpace FUNCTION  (RootPathName AS STRING) AS DOUBLE
ie   PRINT systm.DiskFreeSpace("C:\")  'dir doesn't matter
   
 
SHUTDOWN / LOGOFF
LogOff SUB ()      This will cause the user to logoff. Ask before USING! W 0
Reboot SUB ()       Causes immediate reboot of the system. ASK FIRST! W 0
ShutDown SUB ()      Shuts down the computer. Ask before USING! W 0
ShutDownForce SUB ()      This will cause immediate shutdown. Ask before USING! W 0
 
SYSTEM METRICS
ScrollBarWidth LONG         From GetSystemMetrics R 0
ScrollBarHeight LONG           ""             "" R 0
CaptionBarHeight LONG           ""             "" R 0
WindowBorderWidth LONG           ""             "" R 0
WindowBorderHeight LONG R 0
IconWidth LONG R 0
IconHeight LONG R 0
MouseWheelPresent LONG        the mouse has a wheel, see QFormEx (in QForm doc). R 0
NetworkPresent LONG        Network present flag R 0
SlowProcessor LONG        Slow processor flag, in case you need a fast machine R 0
MenuBarHeight LONG R 0
MenuBarHeight LONG R 0
 
POWER SETTINGS
PercentBattery  FUNCTION%       An integer returning the remaining battery life in the range 0 - 100 R 0
PowerStatus  FUNCTION%    Set or Get the power status.  R/W 0
    sysHibernateAsk = 1        'dialog box asks before hibernating
  sysHibernateForce = 2      'immediate force of hibernating
  sysSleepAsk = 3               'system sleep mode ask with dialog box
  sysSleepForce = 4             'immediate force system into sleep mode
 
ACLineStatus  INTEGER   return values are  R 0

AC_LINE_OFFLINE = &H0
AC_LINE_ONLINE = &H1
AC_LINE_BACKUP_POWER = &H2
AC_LINE_UNKNOWN = &HFF
BATTERY_FLAG_HIGH = &H1
BATTERY_FLAG_LOW = &H2
BATTERY_FLAG_CRITICAL = &H4 
return values can be OR e.g, 
(BATTERY_FLAG_CRITICAL | BATTERY_FLAG_CHARGING)   'both set
BATTERY_FLAG_CHARGING = &H8
BATTERY_FLAG_NO_BATTERY = &H80
BATTERY_FLAG_UNKNOWN = &HFF
BATTERY_PERCENTAGE_UNKNOWN = &HFF
BATTERY_LIFE_UNKNOWN = &HFFFF
 

 

 

QSYSTEM Methods

Method Type Description Params
ShowControlPanel (PanelName AS STRING,index AS INTEGER) AS LONG FUNCTION Open control panel  2


 If you want to open a control panel the PanelName is at least the first  4 characters in the control panel title. Example:  
ShowControlPanel ("firewall, 1) ' show the firewall dialog box applet

Index is the tab# you want to open (not all cases supported, just leave as 1).  Current options are:
   accessibility options           add new hardware        add or remove software         
   dial-up                               directx                         display                                   
   firewall                               font                              game                                     
   internet                               keyboard                     mmdevice                              
   modem                               mouse                          netsetup                                
   passwords                          power management      printers and faxes                   
   regional settings                  scanners                       sounds                                   
   system                                telephone                     themes                                   
   time                                    user                                                                           

QSYSTEM Events
Event Type Occurs when... Params





None  ...

QSYSTEM Example

$INCLUDE "RAPIDQ2.INC"
DEFINT a
DIM systm as QSYSTEM
 ShowMessage "Your operating system name is "+systm.OSName$
 systm.ShowControlPanel("firewall",1)
 systm.ShowControlPanel("sounds",1)

a = systm.PowerStatus
SELECT CASE systm.ACLineStatus
 CASE AC_LINE_OFFLINE
 ShowMessage "AC power not plugged in"
 CASE AC_LINE_ONLINE
 ShowMessage "AC power plugged in" 
 CASE AC_LINE_BACKUP_POWER
 ShowMessage "using backup power"
 CASE AC_LINE_UNKNOWN
 ShowMessage "power source unknown"
END SELECT


 ShowMessage str$(systm.PowerStatus)
 ShowMessage "Percent battery life = " + str$(systm.PercentBattery) + "%"
 ShowMessage str$(systm.ACLineStatus)
 systm.powerstatus = sysSleepAsk
 systm.powerstatus = sysHibernateAsk

ShowMessage "memory before Qform= "_
 + str$(systm.PercentFreeMemory) +_
 "% of a total of " + _
str$(systm.AvailableMemory) + " bytes"
DIM Form AS QFORM
Form.Show
ShowMessage "memory after Qform= " + str$(systm.PercentFreeMemory) + "%"
ShowMessage "Page file memory left = " + str$(systm.PageFileMemory)
ShowMessage "Free space on Hard Drive (MB) = " + str$(systm.DiskFreeSpace("C:\"))
                       Contents