Re: My DLL wants to close the program in which it's running
On Jul 10, 2:43 am, Robert Rollins <coredumper...@gmail.com> wrote:
I'm writing some additions to an existing C++ DLL, and one of the
things I need to add is a generic way to close down the program in
which my DLL is running (so I can close down whatever program may have
loaded it). Can I just call exit(0)? That seems like a really
dramatic way to go about this, and I'm thinking that it might be a bad
idea. Any advice would be greatly appreciated.
There are only two standard ways to normally terminate a
process: return from main, and call exit(). (There's also
abort(), but I don't think we can consider that "normally
terminating".) Generally, it's better to avoid calling exit(),
since that means that the destructors of local variables aren't
called, but unless the main routine has provided for some other
conventions, there's not much else you can do. (In a number of
my programs, I use the convention of throwing an int; main
catch'es the int, and returns the value thrown. But this only
works because main() establishes the convention.)
BTW: you can ignore the idiots complaining about off topic.
Your question is quite appropriate here. But some people just
like to hear themselves talk, and since they can't think of
anything else...
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34