Solved

Intercept the signal for TerminateProcess

Posted on 1997-05-08
3
592 Views
Last Modified: 2013-12-04
Hi,
I have a process, and i want to call an exit procedure when the process is killed by the command "terminate process" from the task manager.
What API's of Windows NT can use to interept this signal and then call my procedure.

thanks
0
Comment
Question by:didede
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
incah earned 50 total points
ID: 1397197
I am calling exit procedures, in response to the WM_CLOSE message, which I get whenever the process is killed as well as
when it is closed normally.
0
 

Author Comment

by:didede
ID: 1397198
Can i have an example of code, and i think it's dont work for process working as service on windows NT.
0
 

Expert Comment

by:incah
ID: 1397199
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
  switch(uMsg) {
       .
       .
       .
  case WM_CLOSE:
       /********************************
       Do whatever cleanup you want here
       *********************************/
       DestroyWindow(hWnd);
       break;
  case WM_DESTROY :
       PostQuitMessage(0);
       break;
  default :
       return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  }
  return(0L);
}
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question