en:docs:fapi:dosfilelocks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
en:docs:fapi:dosfilelocks [2018/08/30 15:06] – created prokusheven:docs:fapi:dosfilelocks [2021/09/18 02:38] prokushev
Line 1: Line 1:
 +{{page>en:templates:fapiint}}
 +
 +====== DosFileLocks ======
 +
 This call locks and unlocks a range in an opened file. This call locks and unlocks a range in an opened file.
  
-==Syntax== +===== Syntax ===== 
- DosFileLocks (FileHandle, UnLockRange, LockRange) +<code c> 
 +DosFileLocks (FileHandle, UnLockRange, LockRange)  
 +</code>
  
-==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. +  FileHandle ([[HFILE]]) - input : File handle. 
-;FileOffset (ULONG) : The offset to the beginning of the range to be unlocked. +  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. 
-;RangeLength (ULONG) : The length of the range to be unlocked. +  FileOffset ([[ULONG]]) : The offset to the beginning 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. +  RangeLength ([[ULONG]]) : The length of the range to be unlocked. 
-;FileOffset (ULONG) : The offset to the beginning of the range to be locked. +  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. 
-;RangeLength (ULONG) : The length of the range to be locked.+  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   NO_ERROR 
-* 6   ERROR_INVALID_HANDLE 
-* 33  ERROR_LOCK_VIOLATION 
-* 36  ERROR_SHARING_BUFFER_EXCEEDED 
  
-==Remarks==+  * 0   NO_ERROR 
 +  * 6   ERROR_INVALID_HANDLE 
 +  * 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 34: 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 "invalid range lock list" or "invalid unlock list" error is returned.  +  * If Block = 1 is specified, an "invalid range lock list" or "invalid unlock list" error is returned.  
-* NewLockIDList is not supported.+  * NewLockIDList is not supported. 
 + 
 +==== Example Code ==== 
 + 
 +=== C Binding ===
  
-==Example Code== +<code c>
-===C Binding=== +
-<PRE>+
 #define INCL_DOSFILEMGR #define INCL_DOSFILEMGR
  
Line 51: Line 65:
  
 USHORT           rc;            /* return code */ USHORT           rc;            /* return code */
-</PRE+</code
-'''Example'''+=== 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 119: Line 134:
                         NULL_RANGE);           /* Lock range */                         NULL_RANGE);           /* Lock range */
       }       }
-</PRE+</code
  
-===MASM Binding=== +=== MASM Binding === 
-<PRE>+ 
 +<code asm>
 EXTRN  DosFileLocks:FAR EXTRN  DosFileLocks:FAR
 INCL_DOSFILEMGR     EQU 1 INCL_DOSFILEMGR     EQU 1
Line 132: Line 148:
  
 Returns WORD Returns WORD
-</PRE>+</code> 
  
 +===== Note =====
  
-====== Note ====== 
  
 Text based on [[http://www.edm2.com/index.php/DosFileLocks]] Text based on [[http://www.edm2.com/index.php/DosFileLocks]]