Hi,
I have a console application.
I need to prevent the user from closing the application by closing the
console window. Is there a way to do that? Maybe to catch the console close
event and cancel it?
Please if there is a way tell me how to do that.
Thanks.
Lau Lei Cheong - 17 Jan 2006 09:00 GMT
Add a call to the following calls at the end.
Console.Write("Press enter to continue...");
Console.ReadLine() ;
"barbutz" <barbutz@discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D:F4B06509-26DD-45C8-BDB9-57837786DEC0@microsoft.com...
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks.
Lau Lei Cheong - 17 Jan 2006 09:11 GMT
Oops... I misread your question.
The fact is, your console application has no control on when the shell
(hence the window contains it) terminates. So you can't stop that.
Your question sounds analogic to "Whether I can keep my program running if
someone shutdowns Windows?"
"Lau Lei Cheong" <leu_lc@yehoo.com.hk> ¼¶¼g©ó¶l¥ó·s»D:eFOYHS0GGHA.3896@TK2MSFTNGP15.phx.gbl...
> Add a call to the following calls at the end.
> Console.Write("Press enter to continue...");
[quoted text clipped - 11 lines]
>>
>> Thanks.
Jeroen Vandezande - 17 Jan 2006 09:44 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> event and cancel it?
> Please if there is a way tell me how to do that.
Hi,
Like the other poster said: you don't have control over the console
window...
If it is that important you should concider making the console app into a
service application.
unless you do a lot of user IO it should not be a problem to do so.
Best Regards,
Jeroen Vandezande