home *** CD-ROM | disk | FTP | other *** search
- Program CheckIt;
-
- Uses
- CRT,
- DOS,
- FileLock;
-
- Var
- f : File of Integer;
- i : integer;
- oldExit : Pointer;
-
- {$F+}
- Procedure MyExit;
- {$F-}
- Begin
- ExitProc := oldExit;
- Seek ( f, 0 );
- While not EOF ( f ) Do
- Begin
- if Unlock ( f, FilePos ( f ), 1 ) Then ;
- Read ( f, i );
- End;
- Close ( f );
- End;
-
- Begin
- oldExit := ExitProc;
- ExitProc := @MyExit;
-
- Assign ( f, 'f:\data.dat' );
- FileMode := 66;
- Reset ( f );
- Repeat
- For i := 1 to 10 do
- Begin
- If ( not Lock ( f, i, 1 ) ) Then
- Begin
- GotoXY ( 1, i );
- WriteLn ( i, ' is locked.' )
- End
- Else
- Begin
- GotoXY ( 1, i );
- WriteLn ( ' ' );
- Repeat Until Unlock ( f, i, 1 );
- End
- End;
- Until KeyPressed;
- End.