回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,24 +1,29 @@
|
|
1
|
-
UWPで作るのでしたら、こちらが参考になるでしょう。
|
2
|
-
[Lock screen personalization sample - Code Samples | Microsoft Docs](https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/personalization/)
|
3
|
-
|
4
|
-
それ以外で作る場合は、NuGetで`Microsoft.Windows.SDK.Contracts`を入れれば簡単に使えます。
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
using
|
11
|
-
using
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
24
|
-
|
1
|
+
UWPで作るのでしたら、こちらが参考になるでしょう。
|
2
|
+
[Lock screen personalization sample - Code Samples | Microsoft Docs](https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/personalization/)
|
3
|
+
|
4
|
+
それ以外で作る場合は、NuGetで`Microsoft.Windows.SDK.Contracts`を入れれば簡単に使えます。
|
5
|
+
|
6
|
+
.NET 6 以降ではさらに簡単になっています(TFMを変えるだけ)
|
7
|
+
[デスクトップ アプリで Windows ランタイム API を呼び出す - Windows apps | Microsoft Learn](https://learn.microsoft.com/ja-jp/windows/apps/desktop/modernize/desktop-to-uwp-enhance)
|
8
|
+
|
9
|
+
```cs
|
10
|
+
using System;
|
11
|
+
using System.Threading.Tasks;
|
12
|
+
using Windows.Storage;
|
13
|
+
using Windows.System.UserProfile;
|
14
|
+
|
15
|
+
namespace Questions254323
|
16
|
+
{
|
17
|
+
class Program
|
18
|
+
{
|
19
|
+
static async Task Main()
|
20
|
+
{
|
21
|
+
var file = await StorageFile.GetFileFromPathAsync(@"C:\Windows\Web\Screen\img101.png");
|
22
|
+
await LockScreen.SetImageFileAsync(file);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
```
|
27
|
+
[StorageFile.GetFileFromPathAsync(String) メソッド (Windows.Storage) - Windows UWP applications | Microsoft Learn](https://learn.microsoft.com/ja-jp/uwp/api/windows.storage.storagefile.getfilefrompathasync)
|
28
|
+
|
29
|
+
[LockScreen.SetImageFileAsync(IStorageFile) メソッド (Windows.System.UserProfile) - Windows UWP applications | Microsoft Learn](https://learn.microsoft.com/ja-jp/uwp/api/windows.system.userprofile.lockscreen.setimagefileasync)
|