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.
filelocking
Re: filelocking
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
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.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: filelocking
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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: filelocking
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.
Also, this isn't a Trick or Tip, so can a mod please move it to
Coding Questions.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: filelocking
PureBasic standard file commands don't open files for sharing. You'll have to go the 'Api' way... sorry.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )