系统相关
首页 > 系统相关> > 在C#中更改Windows锁定屏幕背景图片

在C#中更改Windows锁定屏幕背景图片

作者:互联网

有没有一种方法可以使用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 Desktop应用程序正在执行的操作)

解决方法:

有了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);

标签:windows-8,c
来源: https://codeday.me/bug/20191120/2047921.html