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

how to retrieve path of current .exe

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
I always used gcDefaultDir=sys(5)+sys(2003)to have defaultdir to the location my exe was started (in normal on C:\).
Now I tried same but on D:\somedir

This seems not to work.
What is wrong?

Once the exe is in d:\somedir I expected gcDefaultDir to retrieve also d:\somedir.
I use VFP9.

Any idea?
-Bart
 
Bart,

JUSTPATH(SYS(16)) will always return the full path (including drive letter) of the directory from which the program was launched.

If you are running a PRG in the development environment, it will give the directory containing the PRG. If you are running an EXE, it will give the directory containing the EXE.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
NasibKalsi and Mike,
Both thanks for reply.
Going to include that in my code.
But can you explain what's wrong in my code I used always before?
-Bart
 
Nothing wrong with your code, as long as the sub folder has been created and all related sub directories are in that sub folder. Clicking the exe in windows explorer will give you an error

I would use:

SET DEFAULT TO ADDBS(JUSTPATH(SYS(16))) as the first line in the main program
 
>> always used gcDefaultDir=sys(5)+sys(2003)to have defaultdir to the location my exe was started (in normal on C:\). Now I tried same but on D:\somedir

This seems not to work. What is wrong?

There are three properties on the VFP Application Object (_VFP) that relate to this:

_VFP.StartMode: Number indicating how VFP was started:
0 = Dev, 1 = Application Object, 2 = EXE Automation Server, 3 = STDLL, 4 = VFP Runtime EXE or DLL, 5 = MTDLL

_VFP.FullName: Name of the directory from which VFP was started (normally .\Windows\System32\ for a run-time)

_VFP.ServerName: Full path and file name where the running VFP EXE or DLL is located

To find the location of the EXE use _VFP.ServerName



----
Andy Kramek
Visual FoxPro MVP
 
Andy,

Thanks for reply.
Going to experiment with that.

As far as I can see threat may be closed now.

KR
-Batr
 
Hello Nasib:

Working on customizing of our application for a new national client...Should be done in a week or two, then I will be back in here again.

How have you been?
 
thanks imagecorp: i have been very busy, hopefully 'be free in 2 months+.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top