我想知道是否可以在 C# Metro 应用程序中获取正在运行的 MetroStyle 应用程序的列表。我希望在 Windows 8(而非 Windows Phone)中执行此操作。
最佳答案
我正在使用 Delphi 编写 Alt-Tab 手势替代方案,所以这是我发现列出正在运行的 ModernUI(曾经为人所知的 Metro)应用程序的方式,我仅使用 Windows 8 Release Preview 对其进行了测试,我不知道是否它仍然适用于 Windows 8 RTM。
procedure ShowRunningModernUIApps;
var
metroapp:hwnd;
strAppTitle: array[0..MAX_PATH]of char;
h:integer;
strListApps:string;
begin
metroapp:=FindWindow('Windows.UI.Core.CoreWindow',nil);
if metroapp <>0 then
begin
GetWindowText(metroapp,strAppTitle,MAX_PATH);
strListApps:='Running ModernUI Apps : '+strAppTitle;
h:=0;
while h=0 do
begin
metroapp:=FindWindowEx(0,metroapp,'Windows.UI.Core.CoreWindow',nil);
if metroapp<>0 then
begin
GetWindowText(metroapp,strAppTitle,MAX_PATH);
strListApps:=strListApps+','+strAppTitle;
end
else h:=1; //let's finish the search loop
end;
end;
ShowMessage(strListApps);
end;
这显示了当前正在运行的 ModernUI 应用程序的标题,您可以根据需要存储它们的 HWND。
关于windows-8 - 获取正在运行的 MetroStyle 应用程序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11194759/