How can I retrieve the name (i.e. filename.exe) of a program, from within the program itself?
Announcement
Collapse
No announcement yet.
retrieve program name
Collapse
X
-
-
Shawn,
use the Windows API GetModuleFilename:
Code:#INCLUDE "WIN32API.INC" FUNCTION PBMAIN () AS LONG LOCAL FullPath AS ASCIIZ * %MAX_PATH GetModuleFileName 0, FullPath, %MAX_PATH PRINT "Full path:";FullPath PRINT " EXE name:";RIGHT$(FullPath, -INSTR(-1,FullPath,"\")) WAITKEY$ END FUNCTION
Last edited by Paul Dixon; 3 Nov 2008, 02:43 PM.
Comment
-
EXE.Name$ is new functionality in PBWin9 and PBCC5.
In order to get the executing filename and extension you would use EXE.Namex$ rather than EXE.Name$Paul Squires
FireFly Visual Designer (for PowerBASIC Windows 10+)
Version 3 now available.
http://www.planetsquires.com
Comment
-
And...if you think that someone changed the name of the EXE you can always use that code Michael put in the source code forum to draw a string name out of the resource file.
I updated the code JUST for retrieving a JPEG but you could modify THAT code easy enough to look for "Original filename" or something.Scott Turchin
MCSE, MCP+I
http://www.tngbbs.com
----------------------
True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi
Comment
Comment