Page 1 of 1

How to get the exe directory

Posted: Sun Jan 06, 2008 6:01 am
by Mistrel
Here is a neat thing you can do if you ever get lost in your current directory. :roll:

Code: Select all

Define lpme.MODULEENTRY32

h=CreateToolhelp32Snapshot_($00000008,GetCurrentProcessId_())
lpme\dwSize=SizeOf(MODULEENTRY32)
Module32First_(h,@lpme)

For i=0 To 255
	module.s+Chr(lpme\szModule[i])
Next i

For i=0 To 259
	path.s+Chr(lpme\szExePath[i])
Next i

Debug module.s
Debug path.s

Posted: Sun Jan 06, 2008 6:41 am
by Fluid Byte
Same result, less code:

Code: Select all

Filename$ = Space(#MAX_PATH)
GetModuleFileName_(0,Filename$,#MAX_PATH)
Debug GetFilePart(Filename$) : Debug Filename$

Posted: Sun Jan 06, 2008 7:06 am
by PB
And even less code and natively:

Code: Select all

Debug ProgramFilename()

Posted: Sun Jan 06, 2008 7:36 am
by Mistrel
Thanks for the tip, Fluid Byte! :D
PB wrote:And even less code and natively:

Code: Select all

Debug ProgramFilename()
Less code, yes. But this doesn't return the value I need from within a dll.