home *** CD-ROM | disk | FTP | other *** search
- Program AnotherCExample;
- { This next example will interface several routines from Turbo }
- { Pascal's DOS unit so they are able to be called from the }
- { external C module. This routine also defines the necessary }
- { memory locations to store the SI and DI registers, as Turbo }
- { Pascal trashes these values when C uses them as general }
- { purpose registers. }
- {$A-,F-}
-
- Uses Crt, Dos; { Link in these two standard units }
-
- Var
- Ver : Word; { Location for result of DosVersion call }
- Size : LongInt; { Location for result of DiskSize call }
- Free : LongInt; { Location for result of DiskFree call }
- _rsp : Pointer; { Memory to store the SI and DI registers }
- SiDiStack : Array[0..10] of Word;
-
- {$L List4-8} { Link in required C module }
-
- Procedure StartupC( Var Free, Size : LongInt; Var Ver : Word );
- External;
- { This is the header for the external C module that will be }
- { called by this Turbo Pasaal program. }
-
- Function PasDosVersion : Word;
- { Local Function that will make the actual call to the routine }
- { in the DOS unit. }
-
- Begin
- PasDosVersion := DosVersion;
- End;
-
- Function PasDiskFree( Drive : Byte ) : LongInt;
- { Local Function that will make the actual call to the routine }
- { in the DOS unit. }
- Begin
- PasDiskFree := DiskFree( Drive );
- End;
-
- Function PasDiskSize( Drive : Byte ) : LongInt;
- { Local Function that will make the actual call to the routine }
- { in the DOS unit. }
- Begin
- PasDiskSize := DiskSize( Drive );
- End;
-
- Begin
- _rsp := @SiDiStack; { Point to storage for SI and DI }
- StartupC( Free, Size, Ver ); { Call the C module }
- ClrScr; { Clear the User Screen }
- GotoXY( 1,5 ); { Reposition the Cursor }
- Writeln( 'Current DOS version is ', Lo( Ver ), '.', Hi( Ver ) );
- Writeln( 'Total disk capacity is ', Size );
- Writeln( 'Total bytes free is ', Free );
- Writeln;
- Writeln( 'Press any key to continue...' );
- { Output the results and pause }
- While( Not Keypressed ) Do
- { NOP };
- End.