UserProfilePersonalizationSettings クラス

定義

ユーザーのデスクトップ壁紙とロック画面の背景画像を管理するためのプロパティとメソッドを提供します。

public ref class UserProfilePersonalizationSettings sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UserProfilePersonalizationSettings final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class UserProfilePersonalizationSettings
Public NotInheritable Class UserProfilePersonalizationSettings
継承
Object Platform::Object IInspectable UserProfilePersonalizationSettings
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

using Windows.System.UserProfile;

// Pass in a relative path to a file inside the local appdata folder 
async Task<bool> SetWallpaperAsync(string localAppDataFileName) 
{ 
    bool success = false;
    if (UserProfilePersonalizationSettings.IsSupported())
    {
        var uri = new Uri("ms-appx:///Local/" + localAppDataFileName);
        StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);
        UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current;
        success = await profileSettings.TrySetLockScreenImageAsync(file);
    }
    return success;
} 

注釈

このクラスのインスタンスを取得するには、 Current メソッドを呼び出します。

注意

イメージを複数回設定する場合、新しいイメージ ファイルの名前は、前に設定したイメージとは異なる名前にする必要があります。 前のイメージと同じ名前のファイルを使用して新しいイメージを設定すると、失敗します。

プロパティ

Current

UserProfilePersonalizationSettings の現在のインスタンスを取得します。

メソッド

IsSupported()

デスクトップイメージとロック画面イメージの変更が現在のデバイスでサポートされているかどうかを示す値を取得します。

TrySetLockScreenImageAsync(StorageFile)

指定したイメージ ファイルをロック画面の背景画像として設定しようとします。

TrySetWallpaperImageAsync(StorageFile)

指定したイメージ ファイルをデスクトップの壁紙イメージとして設定しようとします。

適用対象