I want to terminate a application immediately
when the initialize some object failed in the
construct funtion.I try to use
Application->Terminate(); return;
but the application continue creating other forms however.
any hint? TIA
HuangC
Do you tried ExitProcess Win32 API function?
Vladimir.
"Computers don't die, they password away"
Rodolfo Frino
"HuangC" <Hua...@motic.com.cn> wrote in message
news:3f0238c6$1...@newsgroups.borland.com...
> I want to terminate a application immediately
> when the initialize some object failed in the
> construct funtion.I try to use
> Application->Terminate(); return;
> but the application continue creating other
> forms however.
Application->Terminate() simply posts a WM_QUIT message to the message
queue, which will not be processed until later on when the queue begins
being pumped for messages.
If you are doing your initialization in the MainForm's constructor, then
simply throw an exception to indicate a failure. An exception is the only
way to return a failure from a constructor. Throwing an exception from the
MainForm will prevent the other forms from being created.
The alternative is to alter the project's WinMain() function directly, to do
your initializations before the first form is ever created. Then you can
bort your program more gracefully when needed.
Gambit