Programmatically Change Windows 10 Lock Screen Background (on Desktop)

一世执手 提交于 2019-12-03 08:53:55
ThomasT

I've found an easier way using this question Windows 10 Pro lockscreen mass change. All I need to do is set the registry entries under

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP

  • DesktopImagePath
  • DesktopImageUrl
  • LockScreenImagePath
  • LockScreenImageUrl

to the path of the desired picture, which works without UWP or WPF.

As alluded to in my comment, the Windows.System.UserProfile namespace is part of the UWP platform and requires having the Windows 10 SDK installed to utilize.

You can install the SDK by running the Visual Studio Installer, click "Modify" and then choose the "Universal Windows Platform development" workload, or choose the SDK from the list of "Individual Components". More details can be found here.

You may be able to use the library from a desktop .NET app as mentioned in this question How to Interop with Windows Runtime in .NET 4.5 and this link from the answer, but there's no guarantee that Microsoft will continue to allow that so you're probably better off developing using the UWP.

There is a sample from Microsoft for Lock Screen Personalisation on Windows 10 on GitHub here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!