1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Catching a Signal from OS in VC++(MFC)

Discussion in 'MFC' started by manmfc, Sep 22, 2008.

  1. manmfc

    manmfc New Member

    Joined:
    Sep 22, 2008
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. Cosmic_egg

    Cosmic_egg New Member

    Joined:
    Jul 21, 2008
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  3. manmfc

    manmfc New Member

    Joined:
    Sep 22, 2008
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. Cosmic_egg

    Cosmic_egg New Member

    Joined:
    Jul 21, 2008
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page