如何检测是否在 Windows Metro 应用程序进程中运行

How to detect if running inside Windows Metro application process?

本文关键字:Metro Windows 应用程序 进程 运行 是否 何检测 检测      更新时间:2023-10-16

我正在开发一个库,我希望能够检测它是否在 Metro 风格的应用程序中运行,以有选择地禁用/启用某些功能。可能吗?

您可以使用

IMetroMode接口检查您的库是否已加载到 Metro 风格的应用程序中。调用 GetMonitorMode() 方法,如果pMode将保持MMM_METRO则确保在 Metro 应用程序中运行。

这是一个简单的测试:

if (WinJS) {
    // WinJS exists in global if in WinRT app
}