Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

service and SetConsoleCtrlHandler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jan Bares - 04 Oct 2004 16:47 GMT
Hi,

on my Win2k I have a service running. Inside the service start code I use
SetConsoleCtrlHandler() (this is because the service can also be started as
console process for debugging). I realized that my service is shutdown in
some random time (~hours) due to call to HandlerRoutine() routine. I would
like to know how this can happen. I don't suspect that Windows is sending
Ctrl-C to my service at random time...which program can do that?

Aha, just now I realized, that Windows is most probably calling Ctrl-C to
the console when I log off. It seems like all consoles will get Ctrl-C
during log off...comments?

Jan
"Gary Chang" - 06 Oct 2004 08:43 GMT
Hi Jan,

> Aha, just now I realized, that Windows is most probably calling Ctrl-C to
> the console when I log off. It seems like all consoles will get Ctrl-C
> during log off...comments?

Windows will issue a CTRL_LOGOFF_EVENT signal to all console processes on
logging off, and this signal would be processed by your service's
HandlerRoutine, if your custom HandlerRoutine doesn't process this signal,
it would be passed to the default HandlerRoutine.

However,  for a service application, it receives a modified default console
control handler. This modified handler does not call ExitProcess when
processing the CTRL_LOGOFF_EVENT signal...

For more detail information, you can refer to the following MSDN doc:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
e/handlerroutine.asp  

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
"Gary Chang" - 08 Oct 2004 02:44 GMT
Hi Jan,

Do you have any more concerns on this topic, please feel free to post here.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.