bdn.borland.com

Article #29037: Changing the Desktop wallpaper using Delphi

Question


How do you change the Desktop wallpaper for Windows using Delphi?

Solution


You will use the SystemParametersInfo function found in the Windows API to set the desktop wallpaper. Drop a button on your form and in the OnClick event for the button place the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
PicPath: String;
begin
PicPath := 'C:\WINNT\Prairie Wind.bmp';
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pChar(PicPath), SPIF_SENDCHANGE)
end;

Last Modified: 12-SEP-02