| LockBinary |
|
|
|
|
long LockBinary( long FilePosition, // position of region in file long NumberOfElements, // number of elements in region long SizeOfElement, // size of each element BOOL Multilock, // multiple locking flag long Timeout = 5 // operation timeout );
LockBinary( FilePosition As Long, // position of region in file NumberOfElements As Long, // number of elements in region SizeOfElement As Long, // size of each element Multilock As Boolean, // multiple locking flag Timeout As Long = 5 // operation timeout ) As Long
Multiple locking allows locking the same region or its parts many times; with this option enabled object is allowed to lock as many overlapping file regions as needed without regard to their influence on each other. Map of the locks is maintained internally by the object to guarantee correct order of unlocking - file region is physically unlocked only when there are no dependent locks active. Therefore you must assume that after calling UnLock method file region can be still physically locked. Keep in mind that multiple locking is allowed only for the same IXFile object; you cannot lock region that overlaps another region locked by other application, thread or other IXFile object.
Method can be used for locking structured data with fields of various types. In such case entire structure should be treated as a sequence of bytes whose length is equal to total size of the structure specified in SizeOfElement; NumberOfElements specifies how many such structures are locked in file. Method can be also used for locking data of simple types that are not directly supported like Boolean, Date, Currency or Decimal; in such case size of elements must be specified to properly calculate length of region.
Locked region should be eventually unlocked with UnLock method, passing lock handle returned from this method as a parameter.
Visual Basic developers can preferably use LockVariant method for locking structured data.