VB声明 |
||
Declare Function LockFileEx Lib "kernel32" Alias "LockFileEx" (ByVal hFile As Long, ByVal dwFlags As Long, ByVal dwReserved As Long, ByVal nNumberOfBytesToLockLow As Long, ByVal nNumberOfBytesToLockHigh As Long, lpOverlapped As OVERLAPPED) As Long |
||
说明 |
||
与LockFile相似,只是它提供了更多的功能 |
||
返回值 |
||
Long,非零表示成功,零表示失败。会设置GetLastError |
||
参数表 |
||
参数 |
类型及说明 |
|
hFile |
Long,欲锁定文件的句柄 |
|
dwFlags |
Long,指定下述一个或两个常数 |
|
LOCKFILE_FAIL_IMMEDIATELY |
指出如锁定失败,函数应返回一个错误。否则,应用程序线程就会暂时挂起,并一直等待,直到能进行锁定为止 |
|
LOCKFILE_EXCLUSIVE_LOCK |
指出锁定区域不可由另一个线程或进程读写。否则这个区域就只能防范“写”——其他进程仍然能够读取锁定区域的内容 |
|
dwReserved |
Long,未使用,设为零 |
|
nNumberOfBytesToLockLow |
Long,锁定区域包含字符数的低32位 |
|
nNumberOfBytesToLockHigh |
Long,锁定区域包含字符数的高32位 |
|
lpOverlapped |
OVERLAPPED,包含了文件中相对于锁定区域起始处的偏移量 |
|
注解 |
||
锁定区域不可重叠操作(即多个进程同时操作) |