473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How Can a Console APP reject a shutdown/logoff request

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.
Nov 20 '05 #1
2 1684
In article <eg**************@tk2msftngp13.phx.gbl>, Brian Worth wrote:
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.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
* "Brian Worth" <Noname@Nowhere> scripsit:
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%40cpmsftngxa08>

Related:

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

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
7
by: JonBoy | last post by:
Is it possible to put the logoff/shutdown/restart buttons on an ASP page or something similar? If so can anyone point me in the direction of some code please or where I can read how to do it ...
0
by: Allan Bredahl | last post by:
Hi All I am trying to construct an application that is able to cancel a machine shutdown, reboot or logoff. And after performing some stuff to perform the original shutdown order :...
1
by: Jet | last post by:
Hi all, I want to shutdown or reboot or logoff my window by my programme.And when I connect to my machine, and then run ManagementObjectSearcher.Get() method it throw me an exception mean "Cannot...
12
by: Jarod_24 | last post by:
I got a project called "Forms" that hold some forms and stuff in my solution. A argument at startup defines wether to use a From or Console. My plan was to create a myConsole class that would...
6
by: Jm | last post by:
Hi All I have a simple vb.net app that once run for some reason does not allow me to log off or shutdown the pc ? When i try to do so it will close my app and then will only shutdown or logoff...
8
by: Jm | last post by:
Hi All I have an app that when running if a user selects logoff or shutdown from the start menu, it will close itself but not logoff windows or shutdown. From what i have found so far its most...
5
by: erdem | last post by:
Hi, I have a console program that handles events such as SHUTDOWN, LOGOFF. I took the source code from http://www.codeproject.com/win32/console_event_handling.asp What I try to do after...
2
by: mikemiller.innova | last post by:
I developed a C# Windows App that requires a user to input their real name and what they did to the server while they were online. I am going to launch the app att shutdown via a logoff script. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.