Announcement

Collapse
No announcement yet.

retrieve program name

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • retrieve program name

    How can I retrieve the name (i.e. filename.exe) of a program, from within the program itself?

  • #2
    With EXE.Name$.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Sorry to be ignorant about this, but I seem to missing something. Could you be more specific? I can't find any references to exe.name$, besides references to exe and name separately.

      I'm using PBCC 4.04

      Comment


      • #4
        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
        Paul.
        Last edited by Paul Dixon; 3 Nov 2008, 03:43 PM.

        Comment


        • #5
          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


          • #6
            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


            • #7
              That worked for me Paul, thanks.

              exe.name$ looked like a class function so I wondered about that.

              thanks everyone!

              Comment

              Working...
              X