2011-11-24 74 views

回答

18

Shell對象具有WindowSwitcher方法,其可以調用此模式。

這裏是Delphi代碼例如:

uses 
    ComObj; 

procedure EnterWindowSwitcherMode; 
var 
    Shell: OleVariant; 
begin 
    try 
    Shell := CreateOleObject('Shell.Application'); 
    Shell.WindowSwitcher; 
    finally 
    Shell := Unassigned; 
    end; 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
    if Win32MajorVersion >= 6 then // are we at least on Windows Vista ? 
    begin 
    try 
     EnterWindowSwitcherMode; 
    except 
     on E: Exception do 
     ShowMessage(E.ClassName + ': ' + E.Message); 
    end; 
    end; 
end; 


更新:

或者如這裏提到Norbert Willhelm,還存在這實際上介紹了WindowSwitcher方法IShellDispatch5對象接口。因此,這裏的相同的另一個版本...

下面的一段代碼需要Shell32_TLB.pas單元,您可以在Delphi中創建這種方式(請注意,你必須至少有Windows Vista中,其中IShellDispatch5接口使用了第一次):

  • 進入菜單組件/導入組件
  • 繼續選擇導入類型庫
  • 選擇微軟殼牌控制和自動化並完成嚮導

,代碼:

uses 
    Shell32_TLB; 

procedure EnterWindowSwitcherMode; 
var 
    // on Windows Vista and Windows 7 (at this time :) 
    // is Shell declared as IShellDispatch5 object interface 
    AShell: Shell; 
begin 
    try 
    AShell := CoShell.Create; 
    AShell.WindowSwitcher; 
    finally 
    AShell := nil; 
    end; 
end; 
+4

+1非常好確實 –

+4

還有IShellDispatch5。 –

相關問題