UserProfilePersonalizationSettings.TrySetLockScreenImageAsync 메서드

정의

지정된 이미지 파일을 잠금 화면 배경 이미지로 설정하려고 시도합니다.

public:
 virtual IAsyncOperation<bool> ^ TrySetLockScreenImageAsync(StorageFile ^ imageFile) = TrySetLockScreenImageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<bool> TrySetLockScreenImageAsync(StorageFile const& imageFile);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<bool> TrySetLockScreenImageAsync(StorageFile imageFile);
function trySetLockScreenImageAsync(imageFile)
Public Function TrySetLockScreenImageAsync (imageFile As StorageFile) As IAsyncOperation(Of Boolean)

매개 변수

imageFile
StorageFile

잠금 화면 배경으로 설정할 이미지입니다.

반환

비동기 작업의 결과입니다. 배경 이미지가 성공적으로 설정되었으면 true입니다. 그렇지 않으면 false입니다.

특성

예제

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;
} 

설명

참고

모바일 디바이스 패밀리의 경우 2MB(메가바이트) 미만의 잠금 화면 이미지만 설정할 수 있습니다. 비동기 작업이 true를 반환하더라도 더 큰 잠금 화면 이미지를 설정하려고 시도하면 실패합니다.

참고

이미지를 두 번 이상 설정하면 새 이미지 파일의 이름이 이전에 설정한 이미지와 달라야 합니다. 이전 이미지와 이름이 같은 파일을 사용하여 새 이미지를 설정하면 실패합니다.

적용 대상