home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
tpw
/
doc
/
windos.int
< prev
next >
Wrap
Text File
|
1991-05-20
|
13KB
|
358 lines
{*******************************************************}
{ }
{ Turbo Pascal Runtime Library }
{ Windows DOS Interface Unit }
{ }
{ Copyright (c) 1991 Borland International }
{ }
{*******************************************************}
unit WinDos;
{$D-,S-,W-}
interface
{ Flags bit masks }
const
fCarry = $0001;
fParity = $0004;
fAuxiliary = $0010;
fZero = $0040;
fSign = $0080;
fOverflow = $0800;
{ File mode magic numbers }
const
fmClosed = $D7B0;
fmInput = $D7B1;
fmOutput = $D7B2;
fmInOut = $D7B3;
{ File attribute constants }
const
faReadOnly = $01;
faHidden = $02;
faSysFile = $04;
faVolumeID = $08;
faDirectory = $10;
faArchive = $20;
faAnyFile = $3F;
{ Maximum file name component string lengths }
const
fsPathName = 79;
fsDirectory = 67;
fsFileName = 8;
fsExtension = 4;
{ FileSplit return flags }
const
fcExtension = $0001;
fcFileName = $0002;
fcDirectory = $0004;
fcWildcards = $0008;
{ Registers record used by Intr and MsDos }
type
TRegisters = record
case Integer of
0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
end;
{ Typed-file and untyped-file record }
type
TFileRec = record
Handle: Word;
Mode: Word;
RecSize: Word;
Private: array[1..26] of Byte;
UserData: array[1..16] of Byte;
Name: array[0..79] of Char;
end;
{ Textfile record }
type
PTextBuf = ^TTextBuf;
TTextBuf = array[0..127] of Char;
TTextRec = record
Handle: Word;
Mode: Word;
BufSize: Word;
Private: Word;
BufPos: Word;
BufEnd: Word;
BufPtr: PTextBuf;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..16] of Byte;
Name: array[0..79] of Char;
Buffer: TTextBuf;
end;
{ Search record used by FindFirst and FindNext }
type
TSearchRec = record
Fill: array[1..21] of Byte;
Attr: Byte;
Time: Longint;
Size: Longint;
Name: array[0..12] of Char;
end;
{ Date and time record used by PackTime and UnpackTime }
type
TDateTime = record
Year, Month, Day, Hour, Min, Sec: Word;
end;
{ Error status variable }
var
DosError: Integer;
{ DosVersion returns the DOS version number. The low byte of }
{ the result is the major version number, and the high byte is }
{ the minor version number. For example, DOS 3.20 returns 3 in }
{ the low byte, and 20 in the high byte. }
function DosVersion: Word;
{ Intr executes a specified software interrupt with a specified }
{ TRegisters package. NOTE: To avoid general protection faults }
{ when running in protected mode, always make sure to }
{ initialize the DS and ES fields of the TRegisters record with }
{ valid selector values, or set the fields to zero. }
procedure Intr(IntNo: Byte; var Regs: TRegisters);
{ MsDos invokes the DOS function call handler with a specified }
{ TRegisters package. }
procedure MsDos(var Regs: TRegisters);
{ GetDate returns the current date set in the operating system. }
{ Ranges of the values returned are: Year 1980-2099, Month }
{ 1-12, Day 1-31 and DayOfWeek 0-6 (0 corresponds to Sunday). }
procedure GetDate(var Year, Month, Day, DayOfWeek: Word);
{ SetDate sets the current date in the operating system. Valid }
{ parameter ranges are: Year 1980-2099, Month 1-12 and Day }
{ 1-31. If the date is not valid, the function call is ignored. }
procedure SetDate(Year, Month, Day: Word);
{ GetTime returns the current time set in the operating system. }
{ Ranges of the values returned are: Hour 0-23, Minute 0-59, }
{ Second 0-59 and Sec100 (hundredths of seconds) 0-99. }
procedure GetTime(var Hour, Minute, Second, Sec100: Word);
{ SetTime sets the time in the operating system. Valid }
{ parameter ranges are: Hour 0-23, Minute 0-59, Second 0-59 and }
{ Sec100 (hundredths of seconds) 0-99. If the time is not }
{ valid, the function call is ignored. }
procedure SetTime(Hour, Minute, Second, Sec100: Word);
{ GetCBreak returns the state of Ctrl-Break checking in DOS. }
{ When off (False), DOS only checks for Ctrl-Break during I/O }
{ to console, printer, or communication devices. When on }
{ (True), checks are made at every system call. }
procedure GetCBreak(var Break: Boolean);
{ SetCBreak sets the state of Ctrl-Break checking in DOS. }
procedure SetCBreak(Break: Boolean);
{ GetVerify returns the state of the verify flag in DOS. When }
{ off (False), disk writes are not verified. When on (True), }
{ all disk writes are verified to insure proper writing. }
procedure GetVerify(var Verify: Boolean);
{ SetVerify sets the state of the verify flag in DOS. }
procedure SetVerify(Verify: Boolean);
{ DiskFree returns the number of free bytes on the specified }
{ drive number (0=Default,1=A,2=B,..). DiskFree returns -1 if }
{ the drive number is invalid. }
function DiskFree(Drive: Byte): Longint;
{ DiskSize returns the size in bytes of the specified drive }
{ number (0=Default,1=A,2=B,..). DiskSize returns -1 if the }
{ drive number is invalid. }
function DiskSize(Drive: Byte): Longint;
{ GetFAttr returns the attributes of a file. F must be a file }
{ variable (typed, untyped or textfile) which has been assigned }
{ a name. The attributes are examined by ANDing with the }
{ attribute masks defined as constants above. Errors are }
{ reported in DosError. }
procedure GetFAttr(var F; var Attr: Word);
{ SetFAttr sets the attributes of a file. F must be a file }
{ variable (typed, untyped or textfile) which has been assigned }
{ a name. The attribute value is formed by adding (or ORing) }
{ the appropriate attribute masks defined as constants above. }
{ Errors are reported in DosError. }
procedure SetFAttr(var F; Attr: Word);
{ GetFTime returns the date and time a file was last written. }
{ F must be a file variable (typed, untyped or textfile) which }
{ has been assigned and opened. The Time parameter may be }
{ unpacked throgh a call to UnpackTime. Errors are reported in }
{ DosError. }
procedure GetFTime(var F; var Time: Longint);
{ SetFTime sets the date and time a file was last written. }
{ F must be a file variable (typed, untyped or textfile) which }
{ has been assigned and opened. The Time parameter may be }
{ created through a call to PackTime. Errors are reported in }
{ DosError. }
procedure SetFTime(var F; Time: Longint);
{ FindFirst searches the specified (or current) directory for }
{ the first entry that matches the specified filename and }
{ attributes. The result is returned in the specified search }
{ record. Errors (and no files found) are reported in DosError. }
procedure FindFirst(Path: PChar; Attr: Word; var F: TSearchRec);
{ FindNext returs the next entry that matches the name and }
{ attributes specified in a previous call to FindFirst. The }
{ search record must be one passed to FindFirst. Errors (and no }
{ more files) are reported in DosError. }
procedure FindNext(var F: TSearchRec);
{ UnpackTime converts a 4-byte packed date/time returned by }
{ FindFirst, FindNext or GetFTime into a TDateTime record. }
procedure UnpackTime(P: Longint; var T: TDateTime);
{ PackTime converts a TDateTime record into a 4-byte packed }
{ date/time used by SetFTime. }
procedure PackTime(var T: TDateTime; var P: Longint);
{ GetIntVec returns the address stored in the specified }
{ interrupt vector. }
procedure GetIntVec(IntNo: Byte; var Vector: Pointer);
{ SetIntVec sets the address in the interrupt vector table for }
{ the specified interrupt. }
procedure SetIntVec(IntNo: Byte; Vector: Pointer);
{ FileSearch searches for the file given by Name in the list of }
{ directories given by List. The directory paths in List must }
{ be separated by semicolons. The search always starts with the }
{ current directory of the current drive. If the file is found, }
{ FileSearch stores a concatenation of the directory path and }
{ the file name in Dest. Otherwise FileSearch stores an empty }
{ string in Dest. The maximum length of the result is defined }
{ by the fsPathName constant. The returned value is Dest. }
function FileSearch(Dest, Name, List: PChar): PChar;
{ FileExpand fully expands the file name in Name, and stores }
{ the result in Dest. The maximum length of the result is }
{ defined by the fsPathName constant. The result is an all }
{ upper case string consisting of a drive letter, a colon, a }
{ root relative directory path, and a file name. Embedded '.' }
{ and '..' directory references are removed, and all name and }
{ extension components are truncated to 8 and 3 characters. The }
{ returned value is Dest. }
function FileExpand(Dest, Name: PChar): PChar;
{ FileSplit splits the file name specified by Path into its }
{ three components. Dir is set to the drive and directory path }
{ with any leading and trailing backslashes, Name is set to the }
{ file name, and Ext is set to the extension with a preceding }
{ period. If a component string parameter is NIL, the }
{ corresponding part of the path is not stored. If the path }
{ does not contain a given component, the returned component }
{ string is empty. The maximum lengths of the strings returned }
{ in Dir, Name, and Ext are defined by the fsDirectory, }
{ fsFileName, and fsExtension constants. The returned value is }
{ a combination of the fcDirectory, fcFileName, and fcExtension }
{ bit masks, indicating which components were present in the }
{ path. If the name or extension contains any wildcard }
{ characters (* or ?), the fcWildcards flag is set in the }
{ returned value. }
function FileSplit(Path, Dir, Name, Ext: PChar): Word;
{ GetCurDir returns the current directory of a specified drive. }
{ Drive = 0 indicates the current drive, 1 indicates drive A, 2 }
{ indicates drive B, and so on. The string returned in Dir }
{ always starts with a drive letter, a colon, and a backslash. }
{ The maximum length of the resulting string is defined by the }
{ fsDirectory constant. The returned value is Dir. Errors are }
{ reported in DosError. }
function GetCurDir(Dir: PChar; Drive: Byte): PChar;
{ SetCurDir changes the current directory to the path specified }
{ by Dir. If Dir specifies a drive letter, the current drive is }
{ also changed. Errors are reported in DosError. }
procedure SetCurDir(Dir: PChar);
{ CreateDir creates a new subdirectory with the path specified }
{ by Dir. Errors are reported in DosError. }
procedure CreateDir(Dir: PChar);
{ RemoveDir removes the subdirectory with the path specified by }
{ Dir. Errors are reported in DosError. }
procedure RemoveDir(Dir: PChar);
{ GetArgCount returns the number of parameters passed to the }
{ program on the command line. }
function GetArgCount: Integer;
{ GetArgStr returns the Index'th parameter from the command }
{ line, or an empty string if Index is less than zero or }
{ greater than GetArgCount. If Index is zero, GetArgStr returns }
{ the filename of the current module. The maximum length of the }
{ string returned in Dest is given by the MaxLen parameter. The }
{ returned value is Dest. }
function GetArgStr(Dest: PChar; Index: Integer; MaxLen: Word): PChar;
{ GetEnvVar returns a pointer to the value of a specified }
{ environment variable, i.e. a pointer to the first character }
{ after the equals sign (=) in the environment entry given by }
{ VarName. VarName is case insensitive. GetEnvVar returns NIL }
{ if the specified environment variable does not exist. }
function GetEnvVar(VarName: PChar): PChar;