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

有没有一种方法可以使用pinvoke更改锁屏图像(如c#中的墙纸).[DllImport(user32.dll, CharSet = CharSet.Auto)]private static extern Int32 SystemParametersInfo(UInt32 action,UInt32 uParam, string vParam, U...

有没有一种方法可以使用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);

本文标题为:在C#中更改Windows锁定屏幕背景图片

基础教程推荐