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

How can i open a file using vfp 2

Status
Not open for further replies.

poeijer

Programmer
May 29, 2002
69
NL
Hi,

i would like to open different kind of files with their linked programmes through vfp.

e.g. when a filename selected (name.doc) and i click on a button it should start up ms word and open the file.
same with .jpg or .txt files. just the programme that needs to be opened is the programme linked with the extension in my windows explorer.

any ideas how i can accomplish this??
 
ShellExecute will open anything, providing the extension is listed in the registry, and the programm (Like Word is installed on the computer.
Code:
LOCAL lnRetval, lcFile, lcOperation
lcFile = "myText.doc"
lcOperation = "Open"
DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
INTEGER handle,;
STRING @sFile,;
STRING @lp,;
STRING @dir,;
STRING @dir1,;
INTEGER ncmd
lnRetval = ShellExecute(0, lcOperation, lcFile, "", "", 1)
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
thanks a lot, it works perfect..

u got your star :)

 
The above code opens different files etc.... Is there a way to stop code from below being called untill the document which has been openned has been closed???

For example, below could we stop the messagebox appearing until the lcfile has been closed?

lnRetval = ShellExecute(0, lcOperation, lcFile, "", "", 1)
messagebox("test")
 
bebbo,
Go to the UT at click the Downloads picture on the Right, choose Visual FoxPro, then enter "api_apprun" (without the quotes) in the Title box and press enter. You should get back a link to:
"API_APPRUN in .VCX form January 5, 1999 22:59
This contains PROCESS.VCX - a visual class library for the API_APPRUN class described in the FAQ. The class gives the ability to run DOS and WinApps from inside VFP using the CreateProcess() API call, and allows you to wait on termination or return immediately, and allows you to examine the execution status and termination code from an executable run by the class.
It takes care of managing the process and thread handles, removing some potential memory bleeds from not properly disposing of proce..."

Highly recommended.
Rick
 
I got an additional question to this thread.

what if my windows cant find a programme to open the file with. e.g. an unkown extension.

is there a way i can get the 'open with' screen? because now it just doesnt do anything at all.

 
I see everywhere that it needs to be executed something like:

rundll32.exe shell32.dll,OpenAS_runDLL(lcfile)

but how do i do that under foxpro?

hope someone can help me. thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top