Metropoli BBS
VIEWER: os2low.pas MODE: TEXT (CP437)
{█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
{█                                                       █}
{█      Virtual Pascal Examples. Version 1.10            █}
{█      Os/2 Low level programming example               █}
{█      ─────────────────────────────────────────────────█}
{█      Copyright (C) 1995-96 fPrint UK Ltd              █}
{█                                                       █}
{▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}

{ This program demonstrates how to get/set low-level      }
{ information that would normally require BIOS calls or   }
{ access to CMOS RAM if written for DOS.                  }

program Os2Low;

{$PMTYPE VIO}

uses Use32, Os2Def, Os2Base, Strings, VPUtils;

{$IFDEF VPDEMO}
  {&Dynamic VP11Demo.Lib}
{$ENDIF}

Var
  Os2ver : Word;
  s      : String;
  Cols   : Word;
  Rows   : Word;
  Colour : Word;
  Ch     : Char;
  Drives : DriveSet;

begin
  WriteLn('Virtual Pascal Os2Low              Copyright (C) 1996 fPrint UK Ltd');
  Writeln;
  { Get and display the current OS/2 version }
  Os2Ver := VPUtils.Os2Version;
  Writeln( '  OS/2 Version      : ',Lo(Os2Ver),'.',Hi(Os2Ver) );

  { Get the process ID of this process }
  Writeln( '  Process ID        : ','$',Int2Hex(VPUtils.GetForegroundProcessID,4) );

  { Get the boot drive letter }
  ch := VPUtils.GetBootDrive;
  Writeln( '  Boot Drive Is     : ',ch,':' );

  { Get the volume label of boot drive }
  Writeln( '  Boot volume label : ',VPUtils.GetVolumeLabel( ch ) );

  { Get the current time since midnight in milliSeconds }
  Writeln( '  Time in mSec      : ',VPUtils.GetTimemSec );

  { Display OS/2 Boot Drive }
  Writeln( '  Boot Drive is     : ',VPUtils.GetBootDrive,':' );

  { Display list of valid drive letters }
  VPUtils.GetValidDrives( Drives );
  Write  ( '  Valid drives      : ' );
  for ch := 'A' to 'Z' do
    if ch in Drives then
      Write( ch,': ' );
  Writeln;

  { Search PATH for CMD.EXE and display result }
  If VPUtils.FileExistsOnPath( 'CMD.EXE', s ) then
    Writeln( '  File CMD.EXE      : ',s )
  else
    Writeln( '  File CMD.EXE cannot be found on PATH' );

  { Check whether any of the standard files are redirected with pipes }
  Writeln( '  StdIn redirected  : ',not VPUtils.IsFileHandleConsole( 0 ) );
  Writeln( '  StdOut redirected : ',not VPUtils.IsFileHandleConsole( 1 ) );
  Writeln( '  StdErr redirected : ',not VPUtils.IsFileHandleConsole( 2 ) );

  { Display the state of INSert and CAPS Lock }
  Writeln( '  INSert State      : ',VPUtils.GetKeyboardState( kbdstf_Insert_On ) );
  Writeln( '  CAPS Lock State   : ',VPUtils.GetKeyboardState( kbdstf_CapsLock_On ) );

  { Fullscreen only: Set the state of INSert and CAPS Lock }
  Writeln( '  ... Disable Insert, Enable Caps Lock:' );
  SetKeyboardState( kbdstf_Insert_On, False );
  SetKeyboardState( kbdstf_CapsLock_On, True );

  { Re-display keyboard state }
  Writeln( '  INSert State      : ',GetKeyboardState( kbdstf_Insert_On ) );
  Writeln( '  CAPS Lock State   : ',GetKeyboardState( kbdstf_CapsLock_On ) );

  { Display currently used codepage }
  Writeln( '  Current Codepage  : ', VPUtils.GetCodePage );

  { Display current screen size }
  VPUtils.GetVideoModeInfo( Cols, Rows, Colour );
  Writeln( '  Display Mode is   : ',Cols,'x',Rows,'x',Colour );

  { Display bytes allocated on heap (New, GetMem, etc) }
  Writeln( '  Memory allocated  : ', VPUtils.MemUsed );

  { Again, display time in mSec }
  Writeln( '  Time in mSec      : ', VPUtils.GetTimemSec );
end.

[ RETURN TO DIRECTORY ]