Get exe name?

Blitz3D Forums/Blitz3D Programming/Get exe name?

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?

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.

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

It crashes (bad!)

Did you make a mistake?

no the example alone works fine here.

kev

Yes, I was me,

The decls I had was:

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

$ instead of *