home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progpas
/
lockmsg.arj
/
RA_LOCK.PAS
next >
Wrap
Pascal/Delphi Source File
|
1991-08-08
|
2KB
|
78 lines
Unit RA_Lock;
InterFace
Function LockMsgBase(FileName : String) : Boolean; { Lock message base }
{ FileName must be path+name to MSGINFO.BBS }
Function UnLockMsgBase : Boolean; { Unlock message base }
Implementation
Uses Dos,Crt;
Var
Regs : Registers;
i : Integer;
Error : Boolean;
Function LockMsgBase(FileName : String) : Boolean;
Var
Count : Byte;
F : File;
Function GetFileHandle(FileName : String; Var Error : Boolean): Integer;
Begin
FileName:= FileName + #0;
FillChar(Regs,sizeof(Regs),0);
Regs.ah:=$3D; Regs.al:=66; { 66 er Read/Write+Deny none (2+64) }
Regs.ds:=Seg(FileName); Regs.dx:=Ofs(FileName)+1;
MsDos(Regs);
i:=Regs.AX;
If (Lo(Regs.Flags) And $01) > 0 Then
Begin Error := True; GetFileHandle := 0; Exit; End;
GetFileHandle := i;
End;
Function Lock : Boolean;
Begin
Regs.ax:=$5c00; Regs.bx:=i; Regs.cx:=0; Regs.dx:=407; Regs.si:=0; Regs.di:=1;
MsDos(Regs);
If (Lo(Regs.Flags) And $01) > 0 Then Lock:=False
Else Lock:=True;
End;
Begin
Error:=False;
i:=GetFileHandle(FileName,Error);
If Not Error Then
Begin
Count:=0;
While (Not Lock) and (Count<150) and (Regs.ax=$21) Do
Begin
Delay(100);
Inc(Count);
End;
If Count<150 Then LockMsgBase:=True
Else If Regs.ah<>0 Then LockMsgBase:=False;
End
Else LockMsgBase:=False;
End;
Function UnLockMsgBase : Boolean;
Procedure CloseFileHandle(i: integer);
Begin
Regs.ah:=$3E;Regs.bx:=i;
Intr($21,Regs);
End;
Begin
Regs.ax:=$5c01;Regs.bx:=i;Regs.cx:=0;Regs.dx:=407;Regs.si:=0;Regs.di:=1;
Intr($21,Regs);
If (Lo(Regs.Flags) And $01) > 0 Then UnLockMsgBase:=False
Else UnLockMsgBase:=True;
CloseFileHandle(i);
End;
End.