filelocking

Just starting out? Need help? Post your questions and find answers here.
rko
User
User
Posts: 21
Joined: Thu Jul 17, 2008 1:44 pm
Location: germany

filelocking

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: filelocking

Post 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.
rko
User
User
Posts: 21
Joined: Thu Jul 17, 2008 1:44 pm
Location: germany

Re: filelocking

Post 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.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: filelocking

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: filelocking

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: filelocking

Post by blueznl »

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... )
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: filelocking

Post by Rings »

moved
SPAMINATOR NR.1
Post Reply