gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Gcl-devel] RE: Getting full pathname of running executable


From: Mike Thomas
Subject: RE: [Gcl-devel] RE: Getting full pathname of running executable
Date: Fri, 19 Sep 2003 13:09:19 +1000

Hi Camm.

The reason the new 2.6.1 didn't work today is that I discovered that the new
"make install" hard-wired *system-directory* code has broken the Windows
installer, which runs saved_gcl on the target machine during installation to
write out bat and sh startup scripts in the new bin directory.

The scripts actually refer to *system-directory*, expecting it to be set
correctly on the target machine, rather than referring to the machine on
which the installer was built.

Please pardon my ignorance of the semantics of argv[0], but what is wrong
with the code in "o/main.c" which has been up until now setting the
executable path dynamically (and correctly on Windows at least)?

Where were you planning to put the new code discussed last week (included
below)?

Cheers

Mike Thomas




| -----Original Message-----
| From: address@hidden
| [mailto:address@hidden
| Behalf Of Mike Thomas
| Sent: Wednesday, September 10, 2003 11:52 AM
| To: Camm Maguire; address@hidden
| Cc: Aurelien Chanudet
| Subject: [Gcl-devel] RE: Getting full pathname of running executable
|
|
| Hi Camm.
|
| Windows:
|
| ================================================================
| #include <windows.h>
| #include <stdio.h>
|
| #define BUF_SIZE 80
|
| int main ( int argc, char ** argv )
| {
|   char ourpath[BUF_SIZE];
|   GetModuleFileName ( NULL, &ourpath[0], BUF_SIZE );
|   fprintf ( stdout, "The executable is in %s\n", &ourpath[0]  );
|
|   return 0;
| }
|
| ================================================================
|
| address@hidden ~
| $ gcc filename.c -o filename.exe
|
| address@hidden ~
| $ ./filename
| The executable is in C:\msys\1.0\home\miketh\filename.exe
|
| address@hidden ~
| $ cd /c
|
| address@hidden /c
| $ ~/filename
| The executable is in C:\msys\1.0\home\miketh\filename.exe
|
| ================================================================
|
| DWORD GetModuleFileName(
|   HMODULE hModule,
|   LPTSTR lpFilename,
|   DWORD nSize
| );
|
| Parameters
| hModule
| [in] Handle to the module whose path is being requested. If this parameter
| is NULL, GetModuleFileName retrieves the path for the current module.
| lpFilename
| [out] Pointer to a buffer that receives a null-terminated string that
| specifies the fully-qualified path of the module. If the length
| of the path
| exceeds the size specified by the nSize parameter, the function
| succeeds and
| the string is truncated to nSize characters and null terminated.
| The path can have the prefix "\\?\", depending on how the module
| was loaded.
| For more information, see Naming a File.
|
| nSize
| [in] Size of the lpFilename buffer, in TCHARs.
| Return Values
| If the function succeeds, the return value is the length of the string
| copied to the buffer, in TCHARs. If the buffer is too small to hold the
| module name, the string is truncated to nSize, and the function returns
| nSize.
|
| If the function fails, the return value is zero. To get extended error
| information, call GetLastError.
| ================================================================
|
|
| | -----Original Message-----
| | From: Camm Maguire [mailto:address@hidden
| | Sent: Wednesday, September 10, 2003 11:19 AM
| | To: address@hidden
| | Cc: Mike Thomas; Aurelien Chanudet
| | Subject: Getting full pathname of running executable
| |
| |
| | This nonportable proc dependant code is the best I can think of at the
| | moment.  Alternatives, esp. on Windows/Mac?
| |
| |   int p;
| |   char b[PATH_MAX],q[PATH_MAX];
| |
| |   p=getpid();
| |   snprintf(q,sizeof(q),"/proc/%d/exe",p);
| |   realpath(q,b);
| |
| | Take care,
| |
| | --
| | Camm Maguire
| address@hidden
| |
| ==========================================================================
| | "The earth is but one country, and mankind its citizens."  --
| Baha'u'llah
| |
| |
|
|
|
|
| _______________________________________________
| Gcl-devel mailing list
| address@hidden
| http://mail.gnu.org/mailman/listinfo/gcl-devel
|
|






reply via email to

[Prev in Thread] Current Thread [Next in Thread]