set wallpaper

Posted on 2004-09-30
Medium Priority
Last Modified: 2010-04-16
I want to be able to set a .jpg file as the wall paper for my desktop with delphi code.
Question by:harry_haller
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 12

Expert Comment

ID: 12197422
First convert it to BMP and save it in Windows folder. Source for this can be found here.

Then you have to use SystemParametersInfo with SPI_SETDESKWALLPAPER parameter to set the wallpaper. For filename point and the BMP you save before in system folder...
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12198262
Uses SysUtils, Windows, Messages, ShellAPI, ActiveX, ComObj, ShlObj;

procedure SetWallPaper(AName: string);
  TempKey: HKey;
  ActiveDesktop: IActiveDesktop;
  if (RegOpenKeyEx(HKEY_CURRENT_USER, 'Control Panel\Desktop', 0, KEY_ALL_ACCESS, TempKey) = ERROR_SUCCESS) then begin
    RegSetValueEx(TempKey, 'Wallpaper', 0, REG_SZ, PChar(AName), Length(AName));
  ActiveDesktop := CreateComObject(CLSID_ActiveDesktop) as IActiveDesktop;
  OleCheck(ActiveDesktop.SetWallpaper(PWChar(WideString(AName)), 0));
  OleCheck(ActiveDesktop.ApplyChanges(AD_APPLY_REFRESH or AD_APPLY_SAVE or AD_APPLY_FORCE));

Should work for JPG's if you're using the ActiveDesktop. Otherwise, bitmaps only.

Author Comment

ID: 12206900
How do I convert JPG'S to BMP's and how do I set the BMP to be the wallpaper.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question