Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:docs:fapi:dosfilelocks [2021/08/20 04:46] – prokushev | en:docs:fapi:dosfilelocks [2021/09/18 02:39] (current) – prokushev | ||
---|---|---|---|
Line 5: | Line 5: | ||
This call locks and unlocks a range in an opened file. | This call locks and unlocks a range in an opened file. | ||
- | ==Syntax== | + | ===== Syntax ===== |
- | | + | <code c> |
+ | DosFileLocks (FileHandle, | ||
+ | </ | ||
- | ==Parameters== | + | ===== Parameters ===== |
- | ;FileHandle (HFILE) - input : File handle. | + | |
- | ;UnLockRange (PLONG) - input : Address of the structure containing the offset and length of a range to be unlocked. A doubleword of zero indicates that unlocking is not required. | + | |
- | ;FileOffset (ULONG) : The offset to the beginning of the range to be unlocked. | + | |
- | ;RangeLength (ULONG) : The length of the range to be unlocked. | + | |
- | ;LockRange (PLONG) - input : Address of the structure containing the offset and length of a range to be locked. A doubleword of zero indicates that locking is not required. | + | |
- | ;FileOffset (ULONG) : The offset to the beginning of the range to be locked. | + | |
- | ;RangeLength (ULONG) : The length of the range to be locked. | + | |
+ | | ||
+ | |||
+ | ===== Return Code ===== | ||
+ | |||
+ | rc ([[USHORT]]) - return | ||
- | ==Return Code== | ||
- | rc (USHORT) - return | ||
Return code descriptions are: | Return code descriptions are: | ||
- | * 0 | ||
- | * 6 | ||
- | * 33 ERROR_LOCK_VIOLATION | ||
- | * 36 ERROR_SHARING_BUFFER_EXCEEDED | ||
- | ==Remarks== | + | * 0 |
+ | * 6 | ||
+ | * 33 ERROR_LOCK_VIOLATION | ||
+ | * 36 ERROR_SHARING_BUFFER_EXCEEDED | ||
+ | |||
+ | ===== Remarks ===== | ||
DosFileLocks provides a mechanism that allows a process to lock a region in a file for read/write access. The time a region is locked should be short. | DosFileLocks provides a mechanism that allows a process to lock a region in a file for read/write access. The time a region is locked should be short. | ||
Line 38: | Line 45: | ||
If a file is closed (either by a [[DosClose]] request or by a process terminating) and locks are still in effect, the locks are released in no defined order. | If a file is closed (either by a [[DosClose]] request or by a process terminating) and locks are still in effect, the locks are released in no defined order. | ||
- | ===Family API Considerations=== | + | ==== Family API Considerations ==== |
Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restrictions apply to DosFileLocks when coding for the DOS mode: | Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restrictions apply to DosFileLocks when coding for the DOS mode: | ||
- | * If Block = 1 is specified, an " | + | |
- | * NewLockIDList is not supported. | + | * NewLockIDList is not supported. |
+ | |||
+ | ==== Bindings ==== | ||
+ | |||
+ | === C Binding === | ||
- | ==Example Code== | + | <code c> |
- | ===C Binding=== | + | |
- | <PRE> | + | |
#define INCL_DOSFILEMGR | #define INCL_DOSFILEMGR | ||
Line 55: | Line 65: | ||
USHORT | USHORT | ||
- | </PRE> | + | </code> |
- | ''' | + | === Example |
This example opens a file, writes some data to it, locks a block of the data, and then unlocks it. | This example opens a file, writes some data to it, locks a block of the data, and then unlocks it. | ||
- | <PRE> | + | <code c> |
#define INCL_DOSFILEMGR | #define INCL_DOSFILEMGR | ||
Line 123: | Line 134: | ||
NULL_RANGE); | NULL_RANGE); | ||
} | } | ||
- | </PRE> | + | </code> |
- | ===MASM Binding=== | + | === MASM Binding === |
- | <PRE> | + | |
+ | <code asm> | ||
EXTRN DosFileLocks: | EXTRN DosFileLocks: | ||
INCL_DOSFILEMGR | INCL_DOSFILEMGR | ||
Line 136: | Line 148: | ||
Returns WORD | Returns WORD | ||
- | </PRE> | + | </code> |
+ | ===== Note ===== | ||
- | ====== Note ====== | ||
Text based on [[http:// | Text based on [[http:// |