以编程方式更改Windows 10锁定屏幕背景(在桌面上) [英] Programmatically Change Windows 10 Lock Screen Background (on Desktop)
问题描述
如何以编程方式更改/设置锁定屏幕背景图像(使用VB.NET,C#或Visual C ++)?我正在使用Win 10 Pro并拥有Visual Studio 2017 Pro.
How can I programmatically change/set the lock screen background image (using VB.NET, C# or Visual C++)? I am using Win 10 Pro and have Visual Studio 2017 Pro.
我在线上看过,但是大多数解决方案似乎都无效.例如:
I've had a look online but most solutions don't seem to work. For example:
- 两者更改Win 10锁屏图像的倍数C#WPF 和在C#中更改Windows锁定屏幕背景图片提供示例代码,但导入
System.Windows.Media.Imaging
,Windows.Storage
,Windows.Storage.Streams
,<粘贴代码时找不到code> Windows.System.UserProfile .我需要添加特定的参考吗? - 锁定屏幕个性化示例看起来非常有希望,但是在打开时解决方案/项目文件时,Visual Studio抛出错误,提示所提供的格式不可读.
- Both Change Win 10 Lockscreen Image Mutiple Times C# WPF and Change Windows Lock Screen background image in C# provide sample code but the imports
System.Windows.Media.Imaging
,Windows.Storage
,Windows.Storage.Streams
,Windows.System.UserProfile
cannot be found when I paste the code. Do I need to add specific references? - Lock screen personalization sample looks very promising but upon opening the solution/project file, Visual Studio throws an error saying that the provided format is unreadable.
大多数资源(也 Windows开发人员中心-LockScreen类)似乎表明 Windows.System.UserProfile.LockScreen.SetImageFileAsync(file);
但我显然缺少使它运行的特定名称空间/导入/包.
Most sources (also Windows Dev Center - LockScreen Class) seem to suggest
Windows.System.UserProfile.LockScreen.SetImageFileAsync(file);
but I am apparently missing the specific namespace/import/package to make it run.
任何帮助将不胜感激.
推荐答案
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
计算机\ HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ PersonalizationCSP
-
DesktopImagePath
-
DesktopImageUrl
-
LockScreenImagePath
-
LockScreenImageUrl
到所需图片的路径,该路径无需UWP或WPF.
to the path of the desired picture, which works without UWP or WPF.
这篇关于以编程方式更改Windows 10锁定屏幕背景(在桌面上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!