change windows wallpaper using

Pluralsight courses
LinkedIn Premium uses PayScale to estimate job salaries

Premium (Not Free) Video Tutorials

Free Video Tutorials & Free Tools

Also see this video

Want to change windows wallpaper using
There are 2 ways :-

1st way is by

Steps you will do.
•Start visual studio 2005 and create a new window project.
•Set the following properties of the form

Text = "Set Wallpaper"
Size = “1024,750”

•Now drip a picture box control on the form and set its following properties.

Size = “1024,725”
Sizemode = ”centerimage”

•Drop a two button controls on the form and set its following properties as below.

First button control.

Name = " btgetimage"
Text = " Brows For Image"

Second button control.

Name = " btsetwallpaper"
Text = " Set Wallpaper"

•Now drop an openfiledialog control on the form.
•Open you code window and import the following namespace.

Imports System.IO.Directory

•Now declare the function and variables as below which will use win API's to set the wallpaper.

Private Const SPI_SETDESKWALLPAPER As Integer = &H14

Private Const SPIF_UPDATEINIFILE As Integer = &H1

Private Const SPIF_SENDWININICHANGE As Integer = &H2

Private Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer

Const WallpaperFile As String = "c:\wallpaper.bmp"

•Make a function as below.

Friend Sub SetWallpaper(ByVal img As Image)

Dim imageLocation As String

imageLocation = My.Computer.FileSystem.CombinePath(My.Computer.FileSystem.SpecialDirectories.MyPictures, WallpaperFile)


img.Save(imageLocation, System.Drawing.Imaging.ImageFormat.Bmp)


Catch Ex As Exception

MsgBox("There was an error setting the wallpaper: " & Ex.Message)

End Try

End Sub

•Now in the click event of the first button write the following code to open and get the image.
OpenFileDialog1.InitialDirectory = "c:\"

OpenFileDialog1.Filter = "JPG|*.jpg|Bitmap|*.bmp"

Dim dialogresult As DialogResult = OpenFileDialog1.ShowDialog

If dialogresult = Windows.Forms.DialogResult.OK Then

PictureBox1.ImageLocation = OpenFileDialog1.FileName

btsetwallpaper.Enabled = True

End If

In the click event of the second button write following code to set the wallpaper.


2nd way is very easy but requires to logoff

You can use microsoft.win32.registry.setvalue to do the this

and logoff using process.start"logoff.exe"

See if that works and if you have any comments use ip forums

Related posts:

  1. How to change windows login screen using photoshop You might want to develop the windows vista/7 login screen...
  2. Make Logonstudio clone with Note this is tutorial is by idealprogrammer if you...
  3. objects and classes in This is a really great article for beginners who want...
  4. screen capture Do you want to make a app that can...
  5. Dev4Dev Announces Name Change to Brew City Software by: Butler, WI (ContentDesk) April 11, 2006 — Dev4Dev, a...

Related posts brought to you by Yet Another Related Posts Plugin.


One Response to “change windows wallpaper using”
  1. Raaghav says:

    Here is the sample to change Wallpaper, written for Windows form based application. Here use a Timer-Control and 'ShowInTaskbar' option of Form to 'False' and 'WindowState' to 'Minimized'.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.IO;
    //using System.Timers;

    namespace Screen
        public partial class Form1 : Form
            public Form1()
            public static extern bool SystemParametersInfo(UInt32 uiAction, UInt32 uiParam,     string pvParam, UInt32 fWinIni);
            static FileInfo[] images;
            static int currentImage;

            private void timer1_Tick(object sender, EventArgs e)
                const uint SPI_SETDESKWALLPAPER = 20;
                const int SPIF_UPDATEINIFILE = 0x01;
                const int SPIF_SENDWININICHANGE = 0x02;
                SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,     images[currentImage++].FullName, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
                currentImage = (currentImage >= images.Length) ? 0 : currentImage;

            private void Form1_Load(object sender, EventArgs e)
                DirectoryInfo dirInfo = new DirectoryInfo(@"C:\TEMP");
                images = dirInfo.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
                currentImage = 0;


Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Powered by WP Hashcash

This blog uses the cross-linker plugin developed by Web-Developers.Net