home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega CD-ROM 1
/
megacd_rom_1.zip
/
megacd_rom_1
/
MAGAZINE
/
INSIDE_T
/
ITPJAN90.ZIP
/
RECLOCK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-12-15
|
1KB
|
57 lines
UNIT RecLock;
INTERFACE
USES Crt,Dos;
FUNCTION RecordLock(Operation:Integer;
FPointer:Pointer;
LockRec:LongInt): Integer;
PROCEDURE LockError(Error:Integer;
LockRec:LongInt);
IMPLEMENTATION
FUNCTION RecordLock(Operation:Integer;
FPointer:Pointer;
LockRec:LongInt): Integer;
{Returns 0 if lock/unlock was successful,
error number if unsuccessful}
VAR LockRegs:Registers;
StartByte,TotalBytes:LongInt;
BEGIN
TotalBytes:=FileRec(FPointer^).RecSize;
StartByte:=((LockRec-1)*TotalBytes);
WITH LockRegs DO
BEGIN
AH:=$5C;
AL:=Operation;
BX:=FileRec(FPointer^).Handle;
DX:=StartByte;
CX:=StartByte SHR 16;
DI:=TotalBytes;
SI:=TotalBytes SHR 16;
END;
MsDos(LockRegs);
RecordLock:=0;
IF (LockRegs.Flags AND 1 = 1) THEN
RecordLock:=LockRegs.AX;
END;
PROCEDURE LockError(Error:Integer;
LockRec:LongInt);
BEGIN
IF Error=0 THEN
WriteLn('Lock/Unlock successful')
ELSE
BEGIN
Write('Error Locking Record ',LockRec:4,' - ');
CASE Error OF
1: WriteLn('Invalid function code');
6: WriteLn('Invalid Handle');
33: WriteLn('Record already locked/unlocked');
END;
END;
END;
END.