第一个函数:
procedure close_win(win_tital: String);//win_tital是你要关闭的程序窗体标题
var
HWndCalculator : HWnd;
begin
HWndCalculator := FindWindow(nil, win_tital); // close the exist Calculator
if HWndCalculator <> 0 then
begin
SendMessage(HWndCalculator, WM_CLOSE, 0, 0);
// sleep(10000);
Run_update_app(你的外部程序);
end;
Close;
end;