No, it won't work and here's why. User 1 launches your application and changes the file so it can be USEd. Then User 2 double clicks on it in Windows Explorer and opens the file.
>Dear Experts.
>
>I copy following two procedures from a Foxbase prg. All of the DBF files work fine within Exe. But when someone try to open them by double clicking or even in Foxpro then a message appears "Not a dbf file".
>
>May be this is a good trick to avoid databaes files to open without exe.
>Is it possible to use this or such other procedure within Visual Foxpro.
>
>&& FUNCTION PROTECT
>
>PARAMETERS FN
>BUFFER=" "
>HANDLE=FOPEN(FN,2)
>IF HANDLE>-1
> FREAD(HANDLE,@BUFFER,1)
> FBYTE=ASC(BUFFER)
> FSEEK(HANDLE,0,0)
> IF FBYTE=3
> FWRITE(HANDLE,CHR(26),1)
> ENDIF
> FCLOSE(HANDLE)
>ENDIF
>RETURN .T.
>
>
>* Function Unprotect
>
>PARAMETERS FN
>BUFFER=" "
>HANDLE=FOPEN(FN,2)
>IF HANDLE>-1
> FREAD(HANDLE,@BUFFER,1)
> FBYTE=ASC(BUFFER)
> FSEEK(HANDLE,0,0)
> IF FBYTE=26
> FWRITE(HANDLE,CHR(03),1)
> ENDIF
> FCLOSE(HANDLE)
>ENDIF
>RETURN .T.
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer