Archive: Refreshing the desktop background - possible?


Refreshing the desktop background - possible?
Ok, I'm making an installer for an embeded flash desktop, which is basically a very formatted HTML page with a flash file in it. When set to the desktop background, it can make for some very nice desktop apps.

Anyway, I can edit the registry entry for the wallpaper, and I can get the files into %systemroot%\web\wallpaper like they need to be. However, just setting the registry value isn't enough - the desktop background has to be refreshed.

Has anyone done this, or do you know how to? Any help would be appreciated. Thanks!


You could do a Reboot, or you could use the System DLL.
I'd help you but I don't know where to start [System DLL side] :p

-Stu


There is a "Change resolution" Plugin on the NSIS Archive downloads page.
Maybe that could help (source)

-Stu


Thanks, I'll check it out!


I have found the solution here:
http://forums.winamp.com/showthread....hlight=desktop

-Stu :)


Nah, I tried that as well. Like that thread mentions, the desktop refreshes, but the active desktop/wallpaper doesn't update. This is a weird thing that I just don't get. Any reason the deasktop refreshes without sending an update to the wallpaper/active desktop?

Thanks for the help!


Hmm looking at my Registry, once the string setting the path to my desktop image is changed, I have to go to desktop properties to apply it.

I think that a while ago, somone wrote a System dll call which opened up the desktop properties dialog box...

Try searching for that

-Stu


Ok, this should open desktop properties

ExecShell open "rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3"

-Stu


If NSIS can exec an external vbscript, I've got the answer.

I did have the script writing to the registry and refreshing the desktop, but it just wasn't updating to display the new page. this code does it. To test, just create a dummy HTML page and set it in your %systemroot%\web\wallpaper directory, then change the script to point to the correctly named page.

Running the script will set the desktop, open the display properties window, move the selection up/down, then click the OK button. It's dirty, but it gets done!

****************************************
BEGIN CODE
****************************************
' Create the variables needed
Dim WSHShell
Dim WSHApp
Dim strRegKey
Dim strWallpaper
Dim strOSRoot
Dim strDesktop
Dim strDisplayProp

' Create the Wscript Shell object
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHApp = CreateObject("Shell.Application")

' Define the wallpaper
strWallpaper = "%SystemRoot%\Web\Wallpaper\PRWeb.html"
strDesktop = WSHShell.SpecialFolders("Desktop")
strDisplayProp = "Display Properties"

' Create the wallpaper key
strRegKey = "HKEY_CURRENT_USER\"
strRegKey = strRegKey & "Software\"
strRegKey = strRegKey & "Microsoft\"
strRegKey = strRegKey & "Internet Explorer\"
strRegKey = strRegKey & "Desktop\"
strRegKey = strRegKey & "General\"
strRegKey = strRegKey & "Wallpaper"

' Write the key, type, and value
WSHShell.RegWrite strRegKey, strWallpaper, "REG_EXPAND_SZ"

WSHApp.ControlPanelItem cstr("desk.cpl")
Do Until WSHShell.AppActivate (strDisplayProp)
Loop
WSHShell.SendKeys "{down}{up}{tab 3}a~"
****************************************
END CODE
****************************************


If the vb script is compiled into a basic command-line program, then you can use

nsExec::Exec "path_to\myvbapp.exe"

to execute it unseen.

-Stu


Btw, that topic you posted in was created before NSIS 2.0b0 came out :)

-Stu


Cool, so it could exec the vbs - as long as the user has windows scripting host installed....

Is there a function out there for NSIS that'll check for that?


This may be useful:

http://nsis.sourceforge.net/archive/...php?pageid=162

-Stu