>>>>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.
>>
>>A test in 2 VFP IDE does not seem to work. I opened two instances of VFP IDE. I lock the file in one VFP. Then try to lock in another, returns -1. But when I go back to the 1st one and fclose( nHadle), the second instance of VFP IDE still cannot lock the file (returns -1).
>>What am I missing?
>>
>>UPDATE. Now I opened two instances of VFP IDE and can lock the same file in both (using fopen('filename',0)). I am not sure that testing on one computer is possible.
>
>I did that same test right now (Windows 10) and it worked correctly to me (although I used 12 as attribute, because 12 is the one to lock the file).
Yes, it looks like attribute 12 is working for me in Windows 7. So I will change my code from using 0 to 12. Thank you.
"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