可以这样来关闭窗口:
var
  H:THandle
begin
  H:=FindWindow(nil,'網際網路帳戶') ;
  if H<>0 then
    SendMessage(H,WM_SYSCOMMAND,SC_CLOSE,0);
end;

解决方案 »

  1.   

    In the follow code:
    “if temp2  <> 0 then
    temp3:=findwindowex(temp2,0,nil,'取消');
    if temp3 <> 0 then
    sendmessage(temp3,bm_click,0,0) ;”
    I guess that temp3 may be equall to zero.So you can get then result you wanted.
      

  2.   

    如果在我上述的代碼換上你的寫法,'mymail 內容'這個窗體還是無法關閉.
    究竟是什麼原因呢??
    procedure TForm1.Button3Click(Sender: TObject);
    begin
    temp:=findwindow(nil,'網際網路帳戶') ;
    if temp <> 0 then
    temp1:=findwindowex(temp,0,nil,'內容(&P)');
    if temp1 <> 0 then
    sendmessage(temp1,bm_click,0,0)  ;
    sleep(2000);
    temp2:=findwindow(nil,'mymail 內容');
    if temp2  <> 0 then
    temp3:=findwindowex(temp2,0,nil,'取消');
    if temp3 <> 0 then
    sendmessage(temp3,WM_SYSCOMMAND,SC_CLOSE,0) ;
    end;
      

  3.   

    to: blazingfire(烈焰) 但為何分開代碼如下卻可以關閉?
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    temp2:=findwindow(nil,'mymail 內容');
    if temp2  <> 0 then
    temp3:=findwindowex(temp2,0,nil,'取消');
    if temp3 <> 0 then
    sendmessage(temp3,bm_click,0,0) ;
    end;
    So temp3 is not equall to zero!!
      

  4.   

    我的主要問題是用一個button.click連續地調出兩個outlook的選項後無法關閉以下這個
    temp2:=findwindow(nil,'mymail 內容');
    但如果分開代碼,用兩個button去執行卻可以的.
    這是為什麼??