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

API Functions

How to secure your Word document when opening them in VFP. by mgagnon
Posted: 30 Nov 03

This information is based on the MSDN Q192352

For sensitive information contained in Word documents to be opened in VFP, it is sometimes acceptable to rename the extension of the document, in order to prevent it from being opened outside of FoxPro. There are two possible solutions to then open the document in VFP.
  1. Renaming the document "on-the-fly" in VFP, but this solution is dangerous. If the application crashes, the document then remains renamed, an is exposed to abuse.

  2. The second solution is to force the "Open with..." dialog from windows if the extension of the document is not recognized by Windows.

 Here is an example:

Do ShellDoc With "c:\myDocument.dxc"

Procedure ShellDoc()
Lparameters lsFile
#Define SW_HIDE             0
#Define SW_SHOWNORMAL       1
#Define SW_NORMAL           1
#Define SW_SHOWMINIMIZED    2
#Define SW_SHOWMAXIMIZED    3
#Define SW_MAXIMIZE         3
#Define SW_SHOWNOACTIVATE   4
#Define SW_SHOW             5
#Define SW_MINIMIZE         6
#Define SW_SHOWMINNOACTIVE  7
#Define SW_SHOWNA           8
#Define SW_RESTORE          9
#Define SW_SHOWDEFAULT      10
#Define SW_FORCEMINIMIZE    11
#Define SW_MAX              11
#Define SE_ERR_NOASSOC 31
Declare Integer GetDesktopWindow In user32.Dll
Declare Integer GetSystemDirectory In kernel32.Dll ;
    STRING @lsBuffer, ;
    INTEGER liSize
Declare Integer ShellExecute In shell32.Dll ;
    INTEGER, ;
    STRING @lsOperation, ;
    STRING @lsFile, ;
    STRING @lsParameters, ;
    STRING @lsDirectory, ;
    INTEGER liShowCmd
lsOperation = "open"
liRet = ShellExecute(GetDesktopWindow(), @lsOperation, @lsFile, ;
    "", "", SW_SHOWNORMAL)
If liRet = SE_ERR_NOASSOC
    lsSysDir = Space(260)
    liRet = GetSystemDirectory(@lsSysDir, Len(lsSysDir))
    lsSysDir = Substr(lsSysDir, 1, liRet)
    lsRun = "RUNDLL32.EXE"
    lsParameters = "shell32.dll,OpenAs_RunDLL "
    liRet = ShellExecute(GetDesktopWindow(), "open", lsRun,;
        lsParameters + lsFile, lsSysDir, SW_SHOWNORMAL)
Endif
Endproc


Mike Gagnon


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