INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Developer Tools

Protect your apps/functions with a dll by baltman
Posted: 19 Mar 04

*:*************************************
*:* 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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close