在C#中更改Windows锁屏背景图片 [英] Change Windows Lock Screen background image in C#
本文介绍了在C#中更改Windows锁屏背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法来改变喜欢使用的PInvoke在C#中的墙纸锁屏图像。
Is there a way to change the lock screen image like the wall paper in c# using pinvoke.
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern Int32 SystemParametersInfo(UInt32 action,
UInt32 uParam, string vParam, UInt32 winIni);
private static readonly UInt32 SPI_SETDESKWALLPAPER = 20;
private static UInt32 SPIF_UPDATEINIFILE = 0x1;
private static uint MAX_PATH = 260;
// then I call
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, file, SPIF_UPDATEINIFILE);
我想为锁屏做同样的(如Bing的桌面应用正在做)
I'd like to do the same for the lockscreen (like the Bing Desktop app is doing)
推荐答案
由于您的Windows 8标签,是的,你可以:
Given your Windows 8-tag, yes you can:
的 LockScreen.SetImageFileAsync()
,这表现在的在C#中 Windows 8的锁屏界面的个性化样品(错误处理代码省略,检查样品):
LockScreen.SetImageFileAsync()
, as demonstrated on Windows 8 Lock screen personalization sample in C# (error handling code omitted, check the sample):
StorageFile imageFile = await imagePicker.PickSingleFileAsync();
// Application now has access to the picked file, setting image to lockscreen.
// This will fail if the file is an invalid format.
await LockScreen.SetImageFileAsync(imageFile);
这篇关于在C#中更改Windows锁屏背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文