home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vp21beta.zip
/
AEXMPSRC.RAR
/
TESTUTIL
/
TESTUTIL.PAS
Wrap
Pascal/Delphi Source File
|
2000-08-15
|
4KB
|
117 lines
{█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
{█ █}
{█ Virtual Pascal Examples. Version 2.1. █}
{█ VPUtils example █}
{█ ─────────────────────────────────────────────────█}
{█ Copyright (C) 1995-2000 vpascal.com █}
{█ █}
{▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}
{ 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 TestUtil;
{$PMTYPE VIO}
{&CDecl-,T-,X+,Delphi+,Use32+}
uses
Strings, VPSysLow, VPUtils;
const
DrvStr : Array[TDriveType] of PChar
= ('Floppy', 'FAT', 'HPFS', 'Invalid',
'Novell', 'CD ROM', 'Network', 'NTFS', 'Unknown',
'TVFS', 'Linux Ext2', 'JFS');
Var
Osver : Word;
s : String;
Name : String;
Drives : DriveSet;
Ch : Char;
Rows, Cols, Colours: Word;
P1, P2, P3: Pointer;
begin
{ Set screen resolution to 80x50 characters }
VPUtils.SetVideoMode( 80, 50 );
WriteLn('Virtual Pascal TestUtil Copyright (C) 1996-2000 vpascal.com');
Writeln;
{ Get and display the current OS/2 version }
OsVer := VPUtils.OsVersion;
Writeln( ' OS Version : ',Lo(OsVer),'.',Hi(OsVer) );
{ Get the process ID of this process }
Writeln( ' Process ID : ','$',Int2Hex(VPUtils.GetForegroundProcessID,4) );
{ Get the current time since midnight in milliSeconds }
Writeln( ' Time in mSec : ',VPUtils.GetTimemSec );
{ Output current window size }
VPUtils.GetVideoModeInfo( Cols, Rows, Colours );
Writeln( ' Console window is : ',Cols,'x',Rows,', ',Colours,' colours');
{ Get the volume label of drive C: }
Writeln( ' C: volume label : ',VPUtils.GetVolumeLabel( 'C' ) );
{ Get the boot drive letter }
Writeln( ' Boot Drive Is : ',VPUtils.GetBootDrive,':' );
{ Get the drive type for all valid drives }
GetValidDrives(Drives);
for Ch := 'C' to 'Z' do
if Ch in Drives then
Writeln( ' Drive Type ('+Ch+') : ',DrvStr[VPUtils.GetDriveType(Ch)] );
{ Search PATH for CMD.EXE and display result }
Name := {$IFDEF OS2} 'CMD.EXE' {$ELSE} 'COMMAND.COM' {$ENDIF} ;
If VPUtils.FileExistsOnPath( Name, s ) then
Writeln( ' File '+Name+' : ',s )
else
Writeln( ' File '+Name+' cannot be found on PATH' );
{ Check whether any of the standard files are redirected with pipes }
Writeln( ' StdIn redirected : ',not VPUtils.IsFileHandleConsole( SysFileStdIn ) );
Writeln( ' StdOut redirected : ',not VPUtils.IsFileHandleConsole( SysFileStdOut ) );
Writeln( ' StdErr redirected : ',not VPUtils.IsFileHandleConsole( SysFileStdErr ) );
{ Display the state of INSert and CAPS Lock }
Writeln( ' INSert State : ',VPUtils.GetKeyboardState( kbd_Insert ) );
Writeln( ' CAPS Lock State : ',VPUtils.GetKeyboardState( kbd_CapsLock ) );
{ Fullscreen only: Set the state of INSert and CAPS Lock }
Writeln( ' ... Disable Insert, Enable Caps Lock:' );
SetKeyboardState( kbd_Insert, False );
SetKeyboardState( kbd_CapsLock, True );
{ Re-display keyboard state }
Writeln( ' INSert State : ',GetKeyboardState( kbd_Insert ) );
Writeln( ' CAPS Lock State : ',GetKeyboardState( kbd_CapsLock ) );
{ Display currently used codepage }
Writeln( ' Current Codepage : ', VPUtils.GetCodePage );
{ Allocate a few bytes of dynamic memory }
GetMem(P1, 100); GetMem(P2, 1000);
{ Display dynamically allocated memory }
Writeln( ' Dynamic Memory : ', VPUtils.MemUsed, ' (System: ',AllocMemSize,')' );
{ Write the value of pointer P1 }
Writeln( ' Pointer P1 : ', VPUtils.Ptr2Hex(P1));
{ Free the dynamically allocated memory }
FreeMem(P1); FreeMem(P2);
{ Display dynamically allocated memory }
Writeln( ' Dynamic Memory : ', VPUtils.MemUsed, ' (System: ',AllocMemSize,')');
{ Again, display time in mSec }
Writeln( ' Time in mSec : ', VPUtils.GetTimemSec );
Writeln;
Write('Press ENTER');
Readln;
end.