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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to secure your Word document when opening them in VFP.

API Functions

How to secure your Word document when opening them in VFP.

by  Mike Gagnon  Posted    (Edited  )
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.
[ol][li]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.[/li]
[li]The second solution is to force the "Open with..." dialog from windows if the extension of the document is not recognized by Windows.[/li][/ol]
Here is an example:
Code:
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

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