WindowsIntegrityPolicy 类

定义

提供有关当前Windows 10安全模式 (10 S 模式) 的信息,以及模式更改时引发的事件。

public ref class WindowsIntegrityPolicy abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 458752)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class WindowsIntegrityPolicy final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 458752)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class WindowsIntegrityPolicy
Public Class WindowsIntegrityPolicy
继承
Object Platform::Object IInspectable WindowsIntegrityPolicy
属性

Windows 要求

设备系列
Windows 10, version 1809 (在 10.0.17763.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v7.0 中引入)

示例

public class WindowsLockdownExample
{
    public WindowsLockdownExample()
    {
        Windows.System.Profile.WindowsIntegrityPolicy.PolicyChanged += this.WindowsIntegrityPolicy_PolicyChanged;
    }

    ~WindowsLockdownExample()
    {
        Windows.System.Profile.WindowsIntegrityPolicy.PolicyChanged -= this.WindowsIntegrityPolicy_PolicyChanged;
    }

    private void WindowsIntegrityPolicy_PolicyChanged(object sender, object e)
    {
        // Windows secure mode (10 S mode) has changed.

        this.ProcessWindowsIntegrityPolicy();

        if (!Windows.System.Profile.WindowsIntegrityPolicy.IsEnabled)
        {
            // There are certain things that you may want to do when Windows secure mode
            // (10 S mode) has changed from the enabled to the disabled state. For example,
            // a security application might want to offer anti-virus software on this 
            // device.
        }
    }

    public void ProcessWindowsIntegrityPolicy()
    {
        // Check Windows secure mode (10 S mode) status.

        if (Windows.System.Profile.WindowsIntegrityPolicy.IsEnabled)
        {
            // Windows secure mode (10 S mode) is enabled.

            if (Windows.System.Profile.WindowsIntegrityPolicy.IsEnabledForTrial)
            {
                // Furthermore, it has been enabled for trial purposes. Respond accordingly.
                // For example, logging/tagging this device for the organization to 
                // monitor devices that are under trial mode.
            }
            else
            {
                // It has been enabled for normal scenarios. Respond accordingly.
                // For example, don’t try to invoke any process that will be blocked
                // by the policy, or change your UI or error message. For example, 
                // security software could show a different error message about the process
                // being blocked when Windows secure mode (10 S mode) is enabled.
            }
        }

        // Check whether Windows secure mode (10 S mode) can be disabled, and whether disabling is supported.

        if (Windows.System.Profile.WindowsIntegrityPolicy.CanDisable)
        {
            if (Windows.System.Profile.WindowsIntegrityPolicy.IsDisableSupported)
            {
                // Windows secure mode (10 S mode) can be disabled, and disabling is supported.
                // Respond accordingly. For example, report this information back to any cloud-based
                // solution, in case it need to push any policy disabling package to the right devices.
            }
            else
            {
                // Windows secure mode (10 S mode) can be disabled, but disabling is not supported.
                // So, Windows secure mode (10 S mode) can never be changed. Work around this situation.
                // For example, show the appropriate error message when you fail to disable Windows
                // secure mode (10 S mode).
            }
        }
    }
}

注解

Windows 提供 10 S (也称为 Windows 锁定) 模式。 当 Windows 处于 10 S 模式时,只能运行 Microsoft 组件和通用 Windows 平台 (UWP) 应用。 某些特定组件(如 regedit.execmd.exe)也是不允许的。 UWP 应用(尤其是安全和防火墙应用)需要了解当前的 10 S 模式才能正常运行。 当 10 S 模式从启用转换到禁用时,还需要通知此类应用。

属性

CanDisable

获取一个值,该值指示Windows 10安全模式 (10 S 模式) 是否可通过任何方式(在运行时和/或脱机、原始设备制造商 (OEM) 或第三方)禁用。

IsDisableSupported

获取一个值,该值指示 (有关其他必要条件的“说明”,) 是否有任何已发布方式或 API,以便第三方供应商在运行时禁用Windows 10安全模式 (10 S 模式) 。

IsEnabled

获取一个值,该值指示是否 (Windows 锁定模式) 启用Windows 10安全模式 (10 S 模式) 。

IsEnabledForTrial

获取一个值,该值指示是否 (Windows 锁定模式) 启用Windows 10安全模式 (10 S 模式) 以供试用。

事件

PolicyChanged

当当前Windows 10安全模式 (10 S 模式) 更改时引发。

适用于