How to Create lock on file And not Allow the WINDOWS to open a file?
I want to make a program for management the Image files with DELPHI .
now,I want create a password on any files that user select with my program until
these fil开发者_开发技巧es not opened with Windows itself.
How to solve this problem?
Tanks to all.
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
精彩评论