Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lock and unlock a file
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Lock and unlock a file
Miscellaneous
Thread ID:
01638353
Message ID:
01638353
Views:
85
Hi,

I was wondering if anybody would point potential problems with the following approach of locking and unlocking a file:
*-- Lock file
nHandle = fopen( 'MyFile', 0 )

if nHandle < -1
   *-- File not locked
endif 

*-- The code "nHandle = fopen( 'MyFile', 0 )" will return -1 for
*-- any other user on another PC.  Correct?

*-- Unlock file
if nHandle > 0
   fclose( nHandle )
endif  
I want also to be sure that if the user shuts down his/her computer, the lock on the file 'MyFile' is released.

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform