Slideshow Wallpaper Windows 7
Asked Answered
M

1

8

How to set Windows 7 Wallpaper slideshow programmatically?

Setting a normal wallpaper

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern Int32 SystemParametersInfo(UInt32 uiAction, UInt32 uiParam, String pvParam, UInt32 fWinIni);
        private static UInt32 SPI_SETDESKWALLPAPER = 20;
        private static UInt32 SPIF_UPDATEINIFILE = 0x1;
  public void SetImage(string filename)
        {
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, filename, SPIF_UPDATEINIFILE);
        }

What i found until now:

There is an ini-file for the slideshow in

C:\Users\CurrentUser\AppData\Roaming\Microsoft\Windows\Themes\

The wallpaper has to be in the following folder during the slideshow:

C:\Users\CurrentUser\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg

(during a slideshow the file is changing automatically)

Megohm answered 4/7, 2012 at 21:5 Comment(2)
Did you ever find a solution to this? I'm facing the same issue.Melodiemelodion
@Melodiemelodion Until now notMegohm
I
-2

try this

public sealed class Wallpaper
{
Wallpaper() { }

const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

public enum Style : int
{
    Tiled,
    Centered,
    Stretched
}

public static void Set(Uri uri, Style style)
{
    System.IO.Stream s = new System.Net.WebClient().OpenRead(uri.ToString());

    System.Drawing.Image img = System.Drawing.Image.FromStream(s);
    string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp");
    img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp);

    RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
    if (style == Style.Stretched)
    {
        key.SetValue(@"WallpaperStyle", 2.ToString());
        key.SetValue(@"TileWallpaper", 0.ToString());
    }

    if (style == Style.Centered)
    {
        key.SetValue(@"WallpaperStyle", 1.ToString());
        key.SetValue(@"TileWallpaper", 0.ToString());
    }

    if (style == Style.Tiled)
    {
        key.SetValue(@"WallpaperStyle", 1.ToString());
        key.SetValue(@"TileWallpaper", 1.ToString());
    }

    SystemParametersInfo(SPI_SETDESKWALLPAPER,
        0,
        tempPath,
        SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
 }

The original question is this

Inchoate answered 5/7, 2012 at 9:30 Comment(2)
use a timer: private void timer_Tick(object sender, EventArgs e) { // your code for change image every.... }Inchoate
What I wanted to do is: to use the windows built in slideshow wallpaper an not to have an application all the time in the background running!Megohm

© 2022 - 2024 — McMap. All rights reserved.