JCL Help:LockVolume

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Locks the specified volume.


Pascal

 function LockVolume(const Volume: string; var Handle: THandle): Boolean;


Parameters

Parameters Description
const Volume: string The volume to lock this must be a string in the format: * X: Where X is the volume to lock, for example 'a:' * PHYSICALDRIVEX Where X is the 0 based hard disk number, for example 'PHYSICALDRIVE0'. Note: Do not prepend the Volume name with a '\.'. This is done by the function.
var Handle: THandle Receives a handle of the locked device upon successful return.


Return Value

If the function succeeds in locking the volume it returns True and a handle to the specified device in the Handle parameter. If it fails the function returns False and the Handle parameter is undefined.


Description

LockVolume locks the specified volume. Locking a volume will give exclusive access to the specified volume to whoever owns the lock. Subsequent access to the volume must be performed through the returned handle. When you're done with the volume you must call UnLockVolume. Note that to lock a volume there can be no open files on the volume (even a single open file, by whatever process, will cause the function to fail).


See Also

UnlockVolume


About

Unit

JclFileUtils


Donator

Marcel van Brakel


Platforms

Windows


Notes

You must have administrative privileges to lock a volume. The device is, according to Microsoft recommendations, opened with no buffering. This action imposes a number of 'limitations' for subsequent access to the device. For example the alignment of buffers must be on a multiple of the volume's sector size. See the Platform SDK for details.


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page