共用方式為


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,) 是否有任何已發佈方式或 API,讓協力廠商廠商在執行時間停用Windows 10安全模式 (10 S 模式) 。

IsEnabled

取得值,這個值表示是否 (10 S 模式) 啟用Windows 10安全模式) (Windows 鎖定模式) 。

IsEnabledForTrial

取得值,這個值表示是否Windows 10安全模式 (10 S 模式) 啟用, (Windows 鎖定模式) 供試用之用。

事件

PolicyChanged

當目前的Windows 10安全模式 (10 S 模式) 變更時引發。

適用於