Solved

set wallpaper

Posted on 2004-09-30
4
198 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
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
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 100 total points
ID: 12212511
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

15 Experts available now in Live!

Get 1:1 Help Now