I think you should look for a different solution for managing these files, instead of using a lock system, you can use an encryption scheme. because to lock a file you must use the LockFile
or the LockFileEx
function, but these functions block the file only while your application is running. so if you application is stoped by the user or by one exception your files will be unlocked. beside that a real lock in windows does not exist, because exist many applications to access locked files (accessing the files in kernel mode).
from MSDN site
...If a process terminates with a portion
of a file locked or closes a file that
has outstanding locks, the locks are
unlocked by the operating system.
take a look to this link to see a collection of Delphi Encryption components.
My favorite is Delphi Encryption Compedium Part I v.5.2