BackCopy.exe的关闭有一系列条件,我想用另外一个程序结束它,但不想使用结束进程的方式。于是写:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
const int WM_QUERYENDSESSION = 0x0011;
const int WM_CLOSEPROGRAM = 0x8001;
switch (m.Msg)
{
//系统退出消息处理,WM_QUERYENDSESSION是询问程序是否需要关闭,
//要有相应的返回值,0不关闭程序;1关闭程序
case WM_QUERYENDSESSION:
m.Result = (IntPtr)1;
return;
case WM_CLOSEPROGRAM:
textBox1.Text = "";
Close();
break;
default:
break;
}
base.WndProc(ref m);
}
在要它结束的程序中写到:
int FindBackCopy(System.IntPtr