1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| function GetTableUsers(aTable : TTable) : Integer;
var
TmpCursor: hdbicur;
LockInfo: LOCKDesc;
Status: dbiResult;
UserCount : Integer;
const
NO_TABLE_LOCK = 4;
begin
UserCount := 0;
Check(DbiOpenLockList(aTable.Handle, True, True, TmpCursor));
Check(DbiSetToBegin(TmpCursor));
Repeat
Status := DbiGetNextRecord(TmpCursor, dbiNOLOCK, @LockInfo, Nil);
If (Status <> DBIERR_EOF) and (LockInfo.iType = NO_TABLE_LOCK) Then
Inc(UserCount);
Until (Status <> DBIERR_NONE);
Check(DbiCloseCursor(TmpCursor));
Result := UserCount;
end; |
Partager