Autor Beitrag
xtreme
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Sa 28.06.03 16:50 
Hello. I'm new here and I don't speak Deutch well so I'm writting in english.

I'd like to know, how can I lock any file or folder in windows.

Thank you. :lol:
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 28.06.03 20:20 
Just use LockFile() or LockFileEx() and UnlockFile() respectively.

They should be defined in Windows.pas

If you have further problems, don't hesitate to contact me via:
Assarbad AT gmx DOT info
xtreme Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Sa 28.06.03 21:29 
Ok. What about folder?

Ow and how to show message when user click on locked file or folder?

Can you write an example?
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 28.06.03 22:44 
I know neither a reason nor a method to lock folders.

What is " when user click on locked file or folder"? Click in which program? It depends exactly on what you want. There's no generic answer to your question.

Sorry, no example. I neither have time nor will to write one!
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 29.06.03 08:44 
and what exactly does this lockfile () routine do ? how does it lock the file ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Gast
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 29.06.03 11:20 
Zitat:
The LockFile function locks the specified file for exclusive access by the calling process using the specified file handle.


You may lock a specific region of the file only. The mechanism is more or less implemented by OS and FS-driver. To know more about it, try to disassemble or buy the source from MS.

On NT the implementation is AFAIK comparable to *nix implementations. But on 9x/Me there are some flaws - you can note this by studying the Apache source and documentation.

LockFileEx() just lets you specify flags (immediate fail, exclusive vs. shared lock) ... furthermore if fail immediately is not set you may specify an overlap routine that is called if the lock was obtained ... this shows another detail of the LockFile(Ex) routines. It's only possible to lock files exclusively if they are not referenced so far ... else the lock is obtained ASAP.

Locking means prevention of write access to the file - meaning that succeeding access by other process will fail until the file is unlocked.
(Web servers make heavy use of this, e.g. for the log files)