Solved

set wallpaper

Posted on 2004-09-30
4
202 Views
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.
0
Comment
Question by:harry_haller
[X]
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
4 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
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...
0
 
LVL 17

Expert Comment

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

procedure SetWallPaper(AName: string);
var
  TempKey: HKey;
  ActiveDesktop: IActiveDesktop;
begin
  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));
    RegCloseKey(TempKey);
  end;
  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, nil, SPIF_SENDWININICHANGE);
  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));
end;

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

Author Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month9 days, 20 hours left to enroll

623 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