Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Catching a Signal from OS in VC++(MFC) (http://www.go4expert.com/forums/catching-signal-os-vcpp-mfc-t14132/)

manmfc 22Sep2008 19:09

Catching a Signal from OS in VC++(MFC)
 
Hi,
I am new to WINDOWS and VC++ MFC. I am trying to catch a Signal through VC++ MFC from Windows OS. But am not able to find the solution. The need is, one application is running in the user space(eg xyz.exe) and suddenly if the end user(who is using this application on the PC) trying to kill that process from Task Manager. When end user clicks on EndProcess, OS should catch a signal. In UNIX variants I can catch that signal SIGKILL(9). Now am trying to do the same like catching that SIGKILL on UNIX variants by registering a signal handler for that process. In Windows(VC++ MFC) is there any way to do that? Help me out.

Cosmic_egg 24Sep2008 19:54

Re: Catching a Signal from OS in VC++(MFC)
 
Iam Know few things about windows and MFC. not much about unix though.
Iam not very sure what do you mean by catching SIGKILL(9), In the below link it says you can
http://rute.2038bug.com/node12.html.gz
SIGKILL (9)
Kill signal. This is one of the signals that can never be caught by a process. If a process gets this signal it must quit immediately and will not perform any clean-up operations (like closing files or removing temporary files). You can send a process a SIGKILL signal if there is no other means of destroying it.

Okay that was just my doubt....

for you question, what I understand for catching a signal is this,
all messages related to a window application go to WindowProc function
what it can be stopped for further processing. If this is the case you which you meant then
you can see all the message passed to an MFC application using SPY++. When I tried this and closed an application using the taskbar. I did not get any message in the SPY++.

anyway the above info does not solve your problem

manmfc 29Sep2008 17:55

Re: Catching a Signal from OS in VC++(MFC)
 
Hi,
Thanks for your reply. Yes U are right. SIGKILL can't be caught and ignored at all. No other operations can be performed after receiving that signal.
U said about WindowProc(), is it a sys call or API. Means can I use it directly in my program as normal C/CPP function. Or Do I need to specify a C compiler flag for and call it. If possible and if u feel free can u post sample code of using WindowProc.

Cosmic_egg 4Oct2008 09:53

Re: Catching a Signal from OS in VC++(MFC)
 
for winproc see here
http://msdn.microsoft.com/en-us/library/ms633573(VS.85).aspx
for winproc example you can look for it in internet. Many of the MFC projects available on net will have used winproc.


All times are GMT +5.5. The time now is 20:11.