I am trying to learn C# and I want to know how to make a little program to change the desktop background to an image I embedded in the resources.
Asked
Active
Viewed 2,344 times
1
-
2Change the background of what? Your desktop? Your application? – Justin Skiles Jul 29 '12 at 00:36
-
Look here: [link]http://stackoverflow.com/questions/8414635/how-do-i-change-the-wallpaper-programatically – hmmftg Jul 29 '12 at 00:42
1 Answers
2
First get Image from your resource:
var bmp = new Bitmap(
System.Reflection.Assembly.GetEntryAssembly().
GetManifestResourceStream("MyProject.Resources.myimage.png"));
or
var bmp = new Bitmap(WindowsFormsApplication1.Properties.Resources.myimage);
Second Save image to specify Path using Image.Save
.
Finally change desktop background using this code from a SO post:
-
I tried that but I keep getting a run time error that says "A generic error occurred in GDI+." – SpencerJL Jul 29 '12 at 01:07
-
1