Change Windows lock screen background image in C #

Is there a way to change the lock screen image like on a wall 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);

      

I would like to do the same for a lockscreen (like Bing Desktop app)

+3


source to share


1 answer


Given your Windows 8 tag, yes, you can:

LockScreen.SetImageFileAsync()

as shown in Windows 8 Screen Personalization Example in C # (error handling code omitted, check 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);

      

+3


source







All Articles