tinycc-devel
[Top][All Lists]
Advanced

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

Re: Fw: [Tinycc-devel] windows resources LinkRes2Exe.exe by Mike Henning


From: bj
Subject: Re: Fw: [Tinycc-devel] windows resources LinkRes2Exe.exe by Mike Henning
Date: Fri, 06 Oct 2006 05:16:43 +0800
User-agent: Opera Mail/9.02 (Win32)

i got the program name.
char* programname =GetCommandLine();//GetCommandLine(); was what i used before, anyone can set programname to ""
 GetModuleFileName(NULL,programname,MAX_PATH);

now the exe file can create its own manifest file beside itself before it shows any windows, but even if it shows the window it doesn't use the manifest file. so you have to restart it again to see it use the manifest. so i need the restartable program.


On Fri, 06 Oct 2006 04:10:46 +0800, Rob Landley <address@hidden> wrote:

On Thursday 05 October 2006 3:28 pm, Laurens Simonis wrote:
D_FONT),RT_RCDATA);
 > and at finally it worked!!! thank you very much!!
> to all, how does one code a c program that knows its executable name and
 > can restart itself?


The executable name can be found in argv[0] I think. Starting an exe can
be done with system();

#include <stdio.h>

int main(int argc, char **argv)
{
   printf(argv[0]);
   return 0;
}

That's a little oversimplified. The path isn't reliably in there, and the executable might not be in $PATH. On linux, you can exec /proc/self/exe and
expect it to work.  (I don't do Windows.)

Also, system() washes stuff through "/bin/sh", which spawns an extra process and it's a child process rather than a restart. On Linux you want one of the
exec() family of calls (man exec).  Possibly execvp();

Rob



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

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