Is there a way to change the Windows wallpaper using some new feature in .NET 4?
You can use SystemParametersInfo to set the desktop wallpaper. This should work consistently on all versions of windows that your app can run on, however will require some interop.
The following interop declarations are what you need
public const int SPI_SETDESKWALLPAPER = 20;
public const int SPIF_UPDATEINIFILE = 1;
public const int SPIF_SENDCHANGE = 2;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SystemParametersInfo(
int uAction, int uParam, string lpvParam, int fuWinIni);
Which can be used like this to change the desktop wallpaper
SystemParametersInfo(
SPI_SETDESKWALLPAPER, 0, "filename.bmp",
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
You set the wallpaper by updating the registry. Here's an article from 2006 explaining how to do it. The details may have changed with newer versions of Windows, but the concept should be the same. Framework version should be irrelevant.
http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With