Getting Program Exe directory?

Just starting out? Need help? Post your questions and find answers here.
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Getting Program Exe directory?

Post by Chirantha »

How do I get the path to the program's exe and its directory? :(
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

ProgramFilename()
I may look like a mule, but I'm not a complete ass.
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Post by buzzqw »

i use GetCurrentDirectory()

isn't good ?

BHH
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Try this code with a saved and unsaved project to see the difference:

Code: Select all

Debug ProgramFilename()
Debug GetCurrentDirectory()
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

GetCurrentDirectory() can be affected by all kinds of procedures. For example, if your application prints using MS document writer then that will reset the current directory (and cause srod many hours of bug hunting! grrrr....) The point is that GetCurrentDirectory() can never be trusted to return the folder in which the executable resides.
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I'm surprised no one has posted this yet:

Code: Select all

Debug GetFilePart(ProgramFilename()) ; Program name
Debug GetPathPart(ProgramFilename()) ; Program directory
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well, I didn't think it really needed posting what with ProgramFilename() already being listed! :)
I may look like a mule, but I'm not a complete ass.
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Post by buzzqw »

ok, thanks to all!

next time i will use programfilename()

BHH
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

what? did you use 2 accounts to post and then reply?. I sense that your "voice engine" doesn't really need to know all those things you asked on the previous posts ... are you writing malware?.

:lol: should I bash the keyboard and give up?
:?
Chirantha
User
User
Posts: 54
Joined: Sat Jul 16, 2005 7:22 pm

Post by Chirantha »

superadnim wrote:what? did you use 2 accounts to post and then reply?. I sense that your "voice engine" doesn't really need to know all those things you asked on the previous posts ... are you writing malware?.
Ofcourse not :twisted: Quit making me want to make one lol :twisted:
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Also according to another thread, it seems that it can't harm trying to clarify something ... ;)
superadnim wrote:what? did you use 2 accounts to post and then reply?. I sense that your "voice engine" doesn't really need to know all those things you asked on the previous posts ... are you writing malware?.
You obviously mean the 2 accounts with the names "Chirantha" and "buzzqw", no? It seems to be a misunderstanding, and I think the situation is pretty simple:
buzzqw wrote:i use GetCurrentDirectory()

isn't good ?
People wrote some explanations, and then
buzzqw wrote:ok, thanks to all!
Everything as clear as mud? ;)
I think we shouldn't suspect other people of doing strange things without knowing hard facts.

Regards, Little John
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

I know but all those questions seemed to point towards malware to me, I just asked to ask - I didn't blame anyone nor pointed fingers saying he should be burnt with the witches... :lol:

:lol: should I bash the keyboard and give up?
:?
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

Post Reply