Page 1 of 1

filelocking

Posted: Tue Sep 07, 2010 8:23 pm
by rko
hi all,
is there anyway to do filelocking with pb? if not, is there some src for the win api that allows that?

thank in advance for any help.

Re: filelocking

Posted: Tue Sep 07, 2010 9:36 pm
by Trond
What do you mean? The file is locked automatically if you open it for writing with CreateFile() or OpenFile. You don't need to do this manually.

Re: filelocking

Posted: Tue Sep 07, 2010 9:53 pm
by rko
more than one process will open a file and read and write it. i would ike to get something like share and un/lock region.

Re: filelocking

Posted: Tue Sep 07, 2010 10:24 pm
by IdeasVacuum
It depends entirely on exactly what you wish to do - if for example you mean files that are only opened by your application and you wish them to be locked to prevent other Users of your application from trying to open an already open file, you can use a simple record db that has a list of open files and have the app check/update the list accordingly. On the other hand, if you are trying to stop file access by any application to a common file type like a text file, then you need a 'vault' arrangement where the User has to request access to a file.

Re: filelocking

Posted: Tue Sep 07, 2010 10:46 pm
by PB
There's posts in these forums with how to do it. Do a search.
Also, this isn't a Trick or Tip, so can a mod please move it to
Coding Questions.

Re: filelocking

Posted: Wed Sep 08, 2010 8:02 am
by blueznl
PureBasic standard file commands don't open files for sharing. You'll have to go the 'Api' way... sorry.

Re: filelocking

Posted: Wed Sep 08, 2010 8:13 am
by Rings
moved