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

How to determine default directory after app install?

Status
Not open for further replies.

Loomis

Programmer
Jan 4, 2000
30
US
I've created an application (main.exe) using VFP9 and Installshield 5. When the app is installed on a users machine the user, as always, can choose an installation directory other than the default. Question: How do you set the application default directory at design time when the default directory isn't know until after installation. The target machine does not have VFP9 installed on it.
 
If you want to be sure about your program locations always store (install) the program to the same place.
c:\program files\your company\your application\
If your application can store the data on a "free" user defined location it should be OK.

Rob.
 
If you need to get the location at runtime from within your application then Baltman has already given you what you need.

However, to be able to find the application install directory from outside of your VFP application (say for updates or from some other application such as an Office app, you would need to have the install set record the path information into the Windows Registry during install. If your installer doesn't provide for this, then you could add some code to your application to record its location in the Registry when it is first run. Then whenever you need to know where the application is installed on the user's computer, or where the data is stored, or whatever, all you have to do is read from the Registry key(s) you created.

boyd.gif

SweetPotato Software Website
My Blog
 

Loomis,

This is the code I have near the top of my main program:

Code:
SET DEFAULT TO JUSTPATH(SYS(16))

This code will always set the default directory to the directory which contains the EXE file. It works the same, regardless of whether you use InstallShield, or if the user creates a shortcut manually.

The other advantage is that you can use it unmodified when testing in the development environment. Just make sure that your Main.PRG is in the default directory, and everything will still work.

I disagree with Rob, when he says always to use c:\program files\your company\your application\. Although that follows the Microsoft recommendation, it's unsafe to rely on it. There all kinds of reasons why a user might choose to install the app somewhere else -- running off a removable drive rather than a C drive is one that comes to mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top