Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lock and unlock a file
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01638353
Message ID:
01638356
Vues:
57
>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

It looks OK to me and it is also easy to test, you can test it with 2 instances of VFP, you don't really need 2 computers.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform