var
  HWndCalculator : HWnd;
//先定一个句柄变量!
begin  
  HWndCalculator := windows.FindWindow(nil,'Apple');//查找标题为"apple"句柄
  if HWndCalculator <> 0 then //判断窗体是否存在
    SendMessage(HWndCalculator, WM_CLOSE, 0, 0)//发送一个关闭的消息
  else
    ShowMessage('没有发现计算器的启动');
end;

解决方案 »

  1.   

    如果你要时时监视的话,把上述方法写入timer的timer事件中!
      

  2.   

    install a wh_callwndproc/wh_shell to "hook" the window message WM_CREATE, if a this message catched, examine the corresponding
    lparam, this pointer points to a struct(CREATESTRUCT) with the details of that window.
      

  3.   

    但是我开了两个以上的Apple的话,只能关闭最后开启的那个啊?
      

  4.   


    代码写在
    在timer控件的ontimer事件中 并设timer1.enble:=true;