Go Premium for a chance to win a PS4. Enter to Win


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
  • 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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