Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protect your apps/functions with a dll

Developer Tools

Protect your apps/functions with a dll

by  baltman  Posted    (Edited  )
*:*************************************
*:* Coded by Brian Altman
*:*************************************
*:* Inspired by 'simple VFP DLL; code by
*:* Calvin Hsia and John Koziol
*:* found at http://blogs.msdn.com/vsdata/
*:*************************************
*:* Save this portion as a prg and run 1st
*:* Change the 'secret string' or add a more
*:* complicated function to customize
*:*************************************
Code:
IF FILE("baprot.dll")
 DECLARE integer DllUnregisterServer IN baprot.dll
 ?DllUnregisterServer()
 CLEAR DLLS
ENDIF

SET TEXTMERGE TO baprot.prg
SET TEXTMERGE ON NOSHOW
 \DEFINE CLASS baprot AS Session OLEPUBLIC
 \PROCEDURE PassProtect
 \if FILE("pass.txt")
 \ lnPassword=FILETOSTR("pass.txt")
 \else
 \ RETURN .f.
 \endif
  \if SYS(2007,SYS(0)+"YourSecretString")==ALLTRIM(TRANSFORM(lnPassword))
 \ RETURN .t.
 \else
 \ RETURN .f.
 \endif 
 \ENDPROC
 \ENDDEFINE
SET TEXTMERGE TO

BUILD PROJECT baprot FROM baprot
BUILD DLL baprot FROM baprot

*:*************************************
*:* Now your dll is built, call it with this
*:* code from a second prg.
*:*
*:* Figure out what your password should be
*:* using ?SYS(2007,SYS(0)+"YourSecretString")
*:*
*:* For 'true' protection, place some critical
*:* apps functions/methods in the same dll
*:* that can only be fired once the password
*:* is validated.
*:*************************************
Code:
loPass=NEWOBJECT("baprot.baprot")

if FILE("pass.txt")=.f. or lopass.PassProtect=.f.
lnPass=INPUTBOX("Enter Password")
STRTOFILE(lnpass,"pass.txt")
ENDIF

IF lopass.PassProtect
 MESSAGEBOX("success!")
ELSE
 MESSAGEBOX("failure!")
ENDIF
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top