Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Procedure to protect - unprotect database
Message
From
09/02/2007 01:43:24
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Procedure to protect - unprotect database
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01193965
Message ID:
01193965
Views:
68
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.
Next
Reply
Map
View

Click here to load this message in the networking platform