Borland®
Shop
Products Downloads Services Support Partners News & Events Company Community

BDE API Examples (DbiAcqPersistTableLock)

Acquires an exclusive persistent lock on the table preventing other users from using the table or creating a table of the same name.

Place a lock on a non-existent table:

This example is included with Delphi in the BDE32.HLP file.

Create a directory "read only" lock file for accessing Paradox tables on CD-ROMs and "read only" network directories.

This example uses the following input:
CreateReadOnlyLockFile(Database1)
NOTE: Once the .lck files are created, you can move them to any directory to create a read only directory. Also, if this lock is used on a local machine, LOCAL SHARE will need to be set to TRUE.
procedure CreateReadOnlyLockFile(Database: TDatabase);

var

  DBType, Dir: string;

  Len: word;



begin

  SetLength(DBType, DBIMAXNAMELEN + 1);

  // Make sure that the database is of STANDARD type...

  Check(DbiGetProp(hDBIObj(Database.Handle), dbDATABASETYPE, Pchar(DBType),

           DBIMAXNAMELEN, Len));

  SetLength(DBType, Len - 1);

  if DBType <> 'STANDARD' then

    raise EDatabaseError.Create('Directory locks can only be created on STANDARD aliases');

  SetLength(Dir, DBIMAXPATHLEN + 1);

  // Get the directory that the TDatabase is pointing to...

  Check(DbiGetDirectory(Database.Handle, False, PChar(Dir)));

  SetLength(Dir, StrLen(PChar(Dir)));

  // Lock the directory...

  Check(DbiAcqPersistTableLock(Database.Handle, 'paradox.dro', szPARADOX));

end;

Back to BDE API Reference Page


DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.
 
Site Map Search Contact