How Can a Console APP reject a shutdown/logoff request

  • Thread starter Thread starter Brian Worth
  • Start date Start date
B

Brian Worth

I have a console app that would like to reject a shutdown/restart request
unless a certain condition exists. I have written programs with forms in
which you can be notified when the form is about to be closed and can set
Cancel=True to prevent it unless data has been saved first and would like to
do the same with several Console applications that have no forms.

Is there perhaps an event handler that could be set up to do this?

Regards,

Brian.
 
I have a console app that would like to reject a shutdown/restart request
unless a certain condition exists. I have written programs with forms in
which you can be notified when the form is about to be closed and can set
Cancel=True to prevent it unless data has been saved first and would like to
do the same with several Console applications that have no forms.

Is there perhaps an event handler that could be set up to do this?

Regards,

Brian.

You can get this info by using the SetConsoleCtrlHandler API. If you
need it, I have some sample code at home for trapping Console events.
 
* "Brian Worth said:
I have a console app that would like to reject a shutdown/restart request
unless a certain condition exists. I have written programs with forms in
which you can be notified when the form is about to be closed and can set
Cancel=True to prevent it unless data has been saved first and would like to
do the same with several Console applications that have no forms.

PInvoke on 'SetConsoleCtrlHandler'
<http://groups.google.com/groups?selm=FC9Yc9nyBHA.1448@cpmsftngxa08>

Related:

<http://www.gotdotnet.com/Community/...mpleGuid=9aff00ef-e578-410a-9593-b4fd97f9825e>
<http://www.gotdotnet.com/Community/...mpleGuid=b76d1f08-2d79-47bd-825b-0489938aae0f>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top