Func _LockFile($iFileHandle, $bLock = True)
If $iFileHandle Then
If $bLock = True Then
; Lock File
$dLock = DllCall("kernel32.dll", "int", "LockFile", "str", $iFileHandle, "dword", 0, "dword", 32, "dword", 4, "dword", 28)
If Not @error Then
Return 1
Else
SetError(2); Could not lock file
EndIf
Else
; Unlock file
$uLock = DllCall("kernel32.dll", "int", "UnlockFile", "str", $iFileHandle, "dword", 0, "dword", 32, "dword", 4, "dword", 28)
If Not @error Then
Return 1
Else
SetError(3); Could not unlock file
EndIf
EndIf
Else
SetError(1); No File Handle
EndIf
EndFunc |