回答編集履歴

1

見直しキャンペーン中

2023/07/21 10:11

投稿

TN8001
TN8001

スコア9396

test CHANGED
@@ -1,47 +1,29 @@
1
1
  UWPで作るのでしたら、こちらが参考になるでしょう。
2
-
3
2
  [Lock screen personalization sample - Code Samples | Microsoft Docs](https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/personalization/)
4
-
5
-
6
3
 
7
4
  それ以外で作る場合は、NuGetで`Microsoft.Windows.SDK.Contracts`を入れれば簡単に使えます。
8
5
 
9
- ```C#
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)
10
8
 
11
- // 要NuGet Microsoft.Windows.SDK.Contracts
9
+ ```cs
12
-
13
-
14
-
15
10
  using System;
16
-
17
11
  using System.Threading.Tasks;
18
-
19
12
  using Windows.Storage;
20
-
21
13
  using Windows.System.UserProfile;
22
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)
23
28
 
24
-
25
- namespace Questions254323
26
-
27
- {
28
-
29
- class Program
30
-
31
- {
32
-
33
- static async Task Main()
34
-
35
- {
36
-
37
- var file = await StorageFile.GetFileFromPathAsync(@"C:\Windows\Web\Screen\img101.png");
38
-
39
- await LockScreen.SetImageFileAsync(file);
40
-
41
- }
42
-
43
- }
44
-
45
- }
46
-
47
- ```
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)