Tcl8.6.9/Tk8.6.9 Documentation > Tcl C API, version 8.6.9 > FindExec
Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API
- Tcl_FindExecutable, Tcl_GetNameOfExecutable — identify or return the name of the binary file containing the application
- #include <tcl.h>
- const char *
const char *
- char *argv0 (in)
- The first command-line argument to the program, which gives the application's name.
On UNIX platforms this procedure is typically invoked as the very first thing in the application's main program; it must be passed argv as its argument. It is important not to change the working directory before the invocation. Tcl_FindExecutable uses argv0 along with the PATH environment variable to find the application's executable, if possible. If it fails to find the binary, then future calls to info nameofexecutable will return an empty string.
On Windows platforms this procedure is typically invoked as the very first thing in the application's main program as well; Its argv argument is only used to indicate whether the executable has a stderr channel (any non-null value) or not (the value null). If Tcl_SetPanicProc is never called and no debugger is running, this determines whether the panic message is sent to stderr or to a standard system dialog.
Tcl_GetNameOfExecutable simply returns a pointer to the internal full path name of the executable file as computed by Tcl_FindExecutable. This procedure call is the C API equivalent to the info nameofexecutable command. NULL is returned if the internal full path name has not been computed or unknown.binary, executable file