且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

EnumWindows 返回关闭的 Windows 应用商店应用程序

更新时间:2022-12-21 16:51:10

为什么会列出我关闭的 Windows 应用商店应用?

Why are my closed Windows Store apps being listed?

因为它们实际上并未关闭.使用任务管理器、进程选项卡轻松查看.您将看到拥有这些窗口的进程暂停.作为 WinRT(又名 UWP、又名商店、又名现代 UI、又名 Metro)编程框架方法的一部分,现代机器拥有足够的 RAM,即使用户不与它们交互,也可以保持进程运行.使它们再次快速恢复并节省电池寿命.如果其他地方需要 RAM,那么操作系统将通过终止此类进程来挽救它.

Because they are not actually closed. Easy to see with Task Manager, Processes tab. You'll see that the process that owns these windows is suspended. Part of the WinRT (aka UWP, aka Store, aka Modern UI, aka Metro) programming framework approach, modern machines have enough RAM to make it feasible to keep processes running even if the user doesn't interact with them. Brings them back quickly again and saves battery life. If RAM is needed elsewhere then the OS will salvage it by killing such a process.

为什么会列出我的 Edge 选项卡?

Why are my Edge tabs being listed?

因为 Edge 也是一个 WinRT 应用程序.

Because Edge is a WinRT app as well.

如何过滤 Edge 选项卡和关闭的 Windows 应用商店应用?

How can I filter the Edge tabs and the closed Windows Store apps?

鉴于窗口实际上并未关闭,您要过滤的属性并不完全清楚.GetWindowThreadProcessId() 和 IsImmersiveProcess() 可以告诉您您正在处理这样一个进程.考虑 IsWindowVisible().或许这篇博文可以帮到你,也可以告诉你为什么会看到多个窗口.

It is not entirely clear by which property you want to filter, given that the window is in fact not closed. GetWindowThreadProcessId() and IsImmersiveProcess() can tell you that you are dealing with such a process. Consider IsWindowVisible(). Maybe this post can help, also tells you why you see multiple windows.

编辑(尼克·马纳林):

Edit (Nicke Manarin):

通过检查 Cloacked 属性,可以忽略隐藏/后台应用程序:

By checking the Cloacked attribute, it is possible to ignore the hidden/background Store apps:

DwmGetWindowAttribute(handle, (int)DwmWindowAttribute.Cloaked, out bool isCloacked, Marshal.SizeOf(typeof(bool)));

if (isCloacked)
    return true;

编辑 2 (Nicke Manarin):

Edit 2 (Nicke Manarin):

每个 Edge 选项卡的行为就像一个窗口(我相信这与您可以拖动选项卡以创建新窗口的事实有关).

Each Edge tab behaves like a window (I believe it has something to do with the fact that you can drag the tab to create a new window).