Get exe name?

Blitz3D Forums/Blitz3D Programming/Get exe name?

Luke.H(Posted 2005) [#1]
How do you get the name and the programs exe?

I know SystemProperty("AppDir") to your program's directory.

But what about it's name?


Luke.H(Posted 2005) [#2]
This cannot be that hard?

If you pack an exe (with resources) then rename it you will get an error, because its looking for its old name.


Kev(Posted 2005) [#3]
Hi Luke

decls

.lib "kernel32.dll"
GetModuleFileNameA%(hModule%,lpFileName*,nSize%):"GetModuleFileNameA"



an example
lpFileName = CreateBank(256)
str_len = GetModuleFileNameA(0,lpFileName,BankSize(lpFileName))

If str_len > 0 Then
	For grab_exe_name = 0 To str_len-1
		exe_name$ = exe_name + Chr(PeekByte(lpFileName,grab_exe_name))
	Next
EndIf

Print exe_name$
MouseWait
End


kev


Luke.H(Posted 2005) [#4]
It crashes (bad!)

Did you make a mistake?


Kev(Posted 2005) [#5]
no the example alone works fine here.

kev


Luke.H(Posted 2005) [#6]
Yes, I was me,

The decls I had was:

Api_GetModuleFileName%(hModule%,lpFileName$,nSize%):"GetModuleFileNameA"

$ instead of *