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