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

Self-containing an application

Status
Not open for further replies.

pds

Programmer
Jul 2, 2001
9
US
My app runs the Shell function quite a few times and requires a number of files that are essential for the app's calculations. In Shell, I give the app the specific path to each file.

RetVal = Shell("C:\program files\RequiredFile.exe", 0)

But I want to be able to distribute this app. With the code that I have, after moving the app and the required files to a different folder I would have to change the paths listed in the Shell functions in order for the app to use the required files.

It would be much easier if, keeping the app and required files in the same folder, there was a way for the Shell function to be told to look for the required files in the folder that the app is in, without having to mention a specific path. Is there such a way?
 
When your program starts, assign a string variable like so:

strPath = App.Path

Then you can have:
RetVal = Shell(strPath & "\RequiredFile.exe", 0)

The current path can change while your program runs so it's best to grab it as soon as your program starts.
 
Why use the string? why not just app.path & "\file.type"
 
Like I said, the path returned can by App.path can change over the course of time that your program is running (I've noticed this in debug mode, not so much running an compiled executable). Better to be safe and store the path in a variable when your program starts before it has a chance to change.
 
An alternative would be to allow the files to exist "anywhere". Place the names in a table and provide a utility form to set these paths. Use the table information in the shell commands.

You might also look at the functions provided by the external files and incorporate them directly into your app. Shell has the distinct disadvantage of being slow. Since it is part ofthe legacy of DOS, I would wonder if it is even going to exist in the future.
MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top