You can do this:
; -----------------------------------------------------
; Add next two lines to kernel32.decls if needed...
; -----------------------------------------------------
; .lib "kernel32.dll"
; GetModuleFileNameA% (module, name*, size)
; -----------------------------------------------------
; Bank for path name...
Const MAX_PATH = 260 ; Windows max path size!
pbank = CreateBank (MAX_PATH)
; Write executable name to bank...
psize = GetModuleFileNameA (0, pbank, MAX_PATH)
; Read characters in bank...
program$ = ""
For byte = 0 To psize - 1
program$ = program$ + Chr (PeekByte (pbank, byte))
Next
FreeBank pbank
; Ta-da...
RuntimeError "Path: " + Chr (34) + program$ + Chr (34)
If it doesn't run then you need to create a plain text file called kernel32.decls in Blitz3D\userlibs and add the two lines at the top of this code. If it already exists, just add the GetModuleHandleA line to it.
(It'll show blitzcc.exe while running from the IDE, but the real name when run as a standalone executable.)
|