In article <yz*************@invalid.net>,
Arndt Jonasson <do********@invalid.net> wrote:
"Vladimir S. Oka" <no****@btopenworld.com> writes: gum wrote:
> Other than argv[0] is there a way to obtain the name of the executable
> programatically?
AFAIK, no, at least not portable. Why would you want to do it, though?
Rather off-topic now, but the question deserves an answer. Here is one
possible reason: a trick that's sometimes used is to create two
different programs out of the same executable file. When the program
starts, it determines from its name which one it is and handles its
input accordingly.
Vladimir's question was, it seems to me, "Why would you want to
find the name of the executable using some method other than argv[0]?"
Straying further:
On systems with unix-like filesystems, there might not -be- one
single name for an executable because multiple directory entries
can point to the same inode (information node). Then there's small
problems like loopback filesystems that introduce cycles into the
name tree...
On VMS, there might only be a single name in one sense, but it would
seldom be the name that you would want, once you have taken into
account clusters and "logicals"... e.g., you -probably- don't want to
resolve the disk prefix all the way back to internal system notation.
On some operating systems, the only meaningful "name" that a file
might have might be its directory slot number, or might be its disk
sector number.
On Windows, you have to decide whether you want the long names
or the short (DOS-compatible) names.
And so on.
--
Prototypes are supertypes of their clones. -- maplesoft