Click here to Skip to main content
13,344,765 members (50,375 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked
Posted 18 Apr 2004

Desktop Decorator : Changing your wallpaper the easy way in .NET

, 18 Apr 2004
Rate this:
Please Sign up or sign in to vote.
An article describing how to change the wallpaper using .NET and C#


This small article describes how to set the desktop wallpaper. There's really not much to it. The sample application is a Windows Forms application and uses the "Wallpaper" class to set the wallpaper. The class can set wallpaper from most image sources, including images stored locally or on the network/internet. To use the sample application, run it, select an image, and click the Apply button. To test the URL loading, try selecting an image from a web-page, for example,

Using the code

The class for setting the desktop wallpaper is named, not surprisingly, "Wallpaper". It contains one public method name 'Set'. This takes two parameters, a URI that points to the image you want to use, and a "Style" enumeration that specifies how you want the image displayed (tiled, centered, or stretched).

public sealed class Wallpaper 
  public enum Style : int 

  public static void Set ( Uri uri, Style style ) 

Points of Interest

The class first saves your image to a temporary file using a Windows Bitmap format. This allows you to pass other image formats, such as a gif and jpeg files and have them automatically converted and used as wallpaper images. The class also allows source images from almost any location. A URI is passed which describes where the image is located. Feel free to use this code however you please. The usual stuff: if it buggers up your machine/life etc. then it's not my fault!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Steve Dunn
Web Developer
United States United States
I was born at a very young age. My hobbies include reading pornography and killing squirrels.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Member 1003638211-Dec-13 1:18
memberMember 1003638211-Dec-13 1:18 
Generalhi Pin
sandeepparekh2-Jun-11 22:26
membersandeepparekh2-Jun-11 22:26 
QuestionHow change html file to wallpaper? Pin
DimaNikolaevich7-Aug-06 8:18
memberDimaNikolaevich7-Aug-06 8:18 
Questionhow can i get current wallpaper,not use regedit info? Pin
argoli19-Mar-05 17:02
memberargoli19-Mar-05 17:02 
GeneralA little sugestion with Centered Pin
whitesnake6-Feb-05 17:54
memberwhitesnake6-Feb-05 17:54 
GeneralProxies and thanks Pin
Paul Watson20-Aug-04 8:53
sitebuilderPaul Watson20-Aug-04 8:53 
Thanks Dunn, that works great. Just used it in a small Flickr app I was toying around with.

One question though is what is the best way to handle proxy connections? We have a proxy server and the WebClient call didn't get past it. So I changed that to WebRequest and WebResponse calls with a WebProxy and Credentials objects. Is that the best way or does WebClient support proxies too?

Paul Watson
South Africa

Christopher Duncan wrote:
"I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..."

Crikey! ain't life grand?

GeneralRestore original wallpaper Pin
Antonio Barros22-Apr-04 5:24
memberAntonio Barros22-Apr-04 5:24 
GeneralRe: Restore original wallpaper Pin
S0k4r14-Dec-04 0:53
memberS0k4r14-Dec-04 0:53 
GeneralI looked at this method too Pin
Nathan Blomquist19-Apr-04 7:05
memberNathan Blomquist19-Apr-04 7:05 
GeneralRe: I looked at this method too Pin
Jason Henderson20-Apr-04 4:33
memberJason Henderson20-Apr-04 4:33 
GeneralRe: I looked at this method too Pin
Nathan Blomquist20-Apr-04 6:17
memberNathan Blomquist20-Apr-04 6:17 
GeneralGood Hobbies Pin
Norm Almond19-Apr-04 2:59
memberNorm Almond19-Apr-04 2:59 
GeneralRe: Good Hobbies Pin
Uncle Monkey19-Apr-04 3:50
memberUncle Monkey19-Apr-04 3:50 
GeneralRe: Good Hobbies Pin
hxxbin23-Apr-04 5:59
memberhxxbin23-Apr-04 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 19 Apr 2004
Article Copyright 2004 by Steve Dunn
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid