有没有办法使用pinvoke更改c#中墙纸的锁屏图像。
[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桌面应用正在做的那样)
答案 0 :(得分:3)
鉴于您的Windows 8标记,是的,您可以:
LockScreen.SetImageFileAsync()
,如Windows 8 Lock screen personalization sample in C#所示(省略错误处理代码,请查看示例):
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);