>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