Solved

set wallpaper

Posted on 2004-09-30
4
197 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
  • 2
4 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
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
Comment Utility
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
Comment Utility
How do I convert JPG'S to BMP's and how do I set the BMP to be the wallpaper.
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 100 total points
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now