views:

122

answers:

1

Hi friends

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 files not opened with Windows itself.

How to solve this problem?

Tanks to all.

+3  A: 

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

RRUZ
Tank you.May you give me the file lock code with delphi language? the Filelock function not exsist in windows.pas in delphi!
NiliDelphi