SystemSetupInfo 类

定义

提供属性和事件,用于描述现成体验 (OOBE) 生命周期中的当前阶段。

public ref class SystemSetupInfo 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 SystemSetupInfo 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 SystemSetupInfo
Public Class SystemSetupInfo
继承
Object Platform::Object IInspectable SystemSetupInfo
属性

Windows 要求

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

示例

通用 Windows 平台 (UWP) 应用需要知道 OOBE 是否完整,因为它在 OOBE (期间具有特殊行为,例如,用户界面 (UI) 中设置的范围功能,或仅在 OOBE 完成后启动的后台任务) 。 作为 OEM,这可能是在 OOBE 期间运行的应用。

private bool ShouldUseSimpleUserInterface()
{
    var oobeState = Windows.System.Profile.SystemSetupInfo.OutOfBoxExperienceState;

    // When this UWP is shown before OOBE is complete, use a simplified UI
    // with limited options, which matches the style of the rest of OOBE.
    return (oobeState != SystemOutOfBoxExperienceState.Completed);
}

作为 OEM,你想知道设备是否在工厂车间测试期间成功启动到 OOBE。 你希望每台设备都通过此测试作为制造过程中的最终验证步骤,因此在自动化过程中,你希望在 OOBE 正在进行并准备就绪时收到通知。

// Task that has its result set once OOBE is in progress.
private TaskCompletionSource<object> oobeInProgress;

// Called when OOBE state changes. Guaranteed to be called at least once, at
// the time of event registration.
private void OnOobeStateChanged(object sender, object e)
{
    var oobeState = Windows.System.Profile.SystemSetupInfo.OutOfBoxExperienceState;
    if (oobeState == SystemOutOfBoxExperienceState.InProgress)
    {
        oobeInProgress.TrySetResult(null);
    } 
}

private async void WaitForOobeStartedAsync()
{
    oobeInProgress = new TaskCompletionSource<object>();
    Windows.System.Profile.SystemSetupInfo.OutOfBoxExperienceStateChanged += OnOobeStateChanged;
    await oobeInProgress.Task; // NOTE: you could add a timeout here, and fail when hit.
    Windows.System.Profile.SystemSetupInfo.OutOfBoxExperienceStateChanged -= OnOobeStateChanged;
 }

注解

(OOBE) 的现成体验是用户在首次打开Windows 10设备时发生的流。 OOBE 可接受 EULA,设置系统默认区域设置,并帮助设置初始用户帐户。

属性

OutOfBoxExperienceState

获取一个值,该值表示现成体验 (OOBE) 生命周期中的当前阶段。

事件

OutOfBoxExperienceStateChanged

当现成体验生命周期的当前阶段 (OOBE) 更改时引发。

适用于