Archive: Pb : Change wallpaper using System plugin


Pb : Change wallpaper using System plugin
Hi,

I'm trying to change windows wallpaper with the SystemParametersInfo API. I've tried :

System::Call 'user32.dll::SystemParametersInfo(i 20, i 0, t "C:\wall.jpg", i 0) i'


But I only get a white-wallpaper... Output of the function is '0' (failed), and GetLastError sends me '126 : ERROR_MOD_NOT_FOUND The specified module could not be found'

Any ideas ? Thanks !

1. SystemParametersInfoA
2. jpeg support presents in the Active Desktop (may be also in XP?), try bmp first
3. SPIF_SENDCHANGE
4. Redraw desktop.
After this should work :)


1. SystemParametersInfoA
You don't need to put an "A" in front of it because System plugin detects automatically if it's needed.

3. SPIF_SENDCHANGE
And SPIF_UPDATEINIFILE only if you want the file to appear on "Display Properties".

4. Redraw desktop.
You don't need to redraw it manually. The function already does this job for you.

This function requires a bitmap file. (.jpg is not supported here)

Just tried with a bmp file, worked perfectly.

Thanks a lot ! :)


You don't need to redraw it manually. The function already does this job for you.
My beta-testers said that they have few situations when wallpaper update require manual redraw (Active desktop, Win 98, wallpaper removing, may be others, I cannot remember precisely now), so I still advise to use something like

System::Call 'user32.dll::RedrawWindow(i 0, i 0, i 0, i 0x0085) i .r1'

If there any way to change the wallpaper with a successful refresh using active desktop - html and/or files other than a BMP? I've been trying to make a rich desktop installer for forever and just can't get it to work.

By rich desktop, I mean an HTML file loaded with VBScript that also uses flash in the page. Any help would be greatly appreciated!


http://forums.winamp.com/showthread....59#post1386259
I saw "create IActiveDesktop interface" in the KichiK' script, but this may serve as a base only for your task. May be easier to write a plug-in. AD works with all types supported by current IE. You can add html as "desktop component" with pActiveDesktop->AddDesktopItem() method and set wallpaper using pActiveDesktop->SetWallpaper() (2 different parts of AD). Or you can set jpeg image as a background of your AD "html component". A lot of samples in Inet.


There's a way to change wallpaper using VBScript and the Windows Scriptig Host object, but it's kinda dirty. It'll add anything to the desktop - jpg, bmp, html... Here's some code:

Dim WallPaper
Dim WP : WP = "C:\Windows\Web\Wallpaper\test.html"
Set WallPaper = CreateObject("WScript.Shell")
With WallPaper
.Regwrite "HKCU\Control Panel\Desktop\WallPaper", WP
.Run "control desk.cpl" ' run display properties
WScript.Sleep 50
.AppActivate "Desktop Properties" ' activate desktop tab
WScript.Sleep 50
If WP = "" Then
For I = 0 to 20
WScript.Sleep 50
.SendKeys "{up}" ' move the selectiong up to "none"
Next
Else
WScript.Sleep 50
.SendKeys "{up}" ' toggle the selection up
WScript.Sleep 50
.SendKeys "{down}" ' then toggle down (we've now selected the wallpaper)
End If
WScript.Sleep 50
.SendKeys "~" ' hit OK
End With
Set WallPaper = nothing