Refreshing the desktop wallpaper

J

Jeffery Tyree

My application is written in C#.NET and will run on XP machines. I would
like to programmatically change the desktop wallpaper. Reading and writing
registry values is no problem but I'm having difficulty figuring out what
the proper message is and how to send it to the system message queue so that
the desktop is painted with the new wallpaper. I ask that someone please
provide some sample code for this.

TIA.
 
N

Nicholas Paldino [.NET/C# MVP]

Jeffery,

Writing to the registry is not the recommended way to do this. The
reason being is that the location of the path of the wallpaper could be
changed by MS, and then your application would break.

Instead, you need to call the SystemParametersInfo API function, passing
the SPI_SETDESKWALLPAPER option in, along with the path to the bitmap for
the wallpaper.

Hope this helps.
 
J

Jeffery Tyree

Thank you Nicholas.


Nicholas Paldino said:
Jeffery,

Writing to the registry is not the recommended way to do this. The
reason being is that the location of the path of the wallpaper could be
changed by MS, and then your application would break.

Instead, you need to call the SystemParametersInfo API function,
passing the SPI_SETDESKWALLPAPER option in, along with the path to the
bitmap for the wallpaper.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jeffery Tyree said:
My application is written in C#.NET and will run on XP machines. I would
like to programmatically change the desktop wallpaper. Reading and
writing registry values is no problem but I'm having difficulty figuring
out what the proper message is and how to send it to the system message
queue so that the desktop is painted with the new wallpaper. I ask that
someone please provide some sample code for this.

TIA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top