Hi Tony I considered a flag in the file, but there will be a problem if there is a power cut or PC crash and the flag is left in the file, and everyone is locked out. It will need some manual utility to reset it.
Regarding a server type application, that would work. It would only need to manage the "locking", and not the reading or writing to the file. Now someone mentioned the Windows API LockFile() and UnlockFile(). I discovered this before my first post, but reading the description on MSDN, it mentioned blocking other threads access to the file, so I thought it was limited to the single PC. It doesn't mention anything about multi-user locking. But reading info on other sites now and it appears this will work across separate PC's, so this could be the simple solution. Thanks, Ross. ----- Original Message ----- From: "Tony Foale" <[EMAIL PROTECTED]> To: <delphi@elists.org> Sent: Tuesday, March 20, 2007 12:48 AM Subject: File/record locking << I only want the file not writable by another PC while a record is being written. When I'm finished writing a record, which may take a few milliseconds, I want others to be able to write to the file immediately afterwards. >> Ages ago I had a similar requirement and the solution was both simple and functional. Just set a "It's my turn - get lost" flag. When nobody is writing the flag is false. The first person who starts to write sets the flag to true and he is allowed to write, the others who want to write see the flag and keep testing it until it becomes false again when the first writer has finished, ad infinitum. You just need to consider what to do if two people try to write at exactly the same moment. In practice I was never troubled by this, one always got there first, but if this is a concern you could easily set up a queue and assign priority rank to the user's (more likely their computers). -- Regards, Tony Foale EspaƱa / Spain www.tonyfoale.com [EMAIL PROTECTED] _______________________________________________ Delphi mailing list -> Delphi@elists.org http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> Delphi@elists.org http://www.elists.org/mailman/listinfo/delphi