Windows wallpaper: not just BMPs?
-
09-06-2019 - |
Question
I've read in a couple of places that the desktop wallpaper can be set to an HTML document. Has anyone had any success changing it programmatically?
The following snippet of VB6 helps me set things up for BMPs but when I try to use it for HTML, I get a nice blue background and nothing else.
Dim reg As New StdRegistry
Public Function CurrentWallpaper() As String
CurrentWallpaper = reg.ValueEx(HKEY_CURRENT_USER, "Control Panel\Desktop", "Wallpaper", REG_SZ, "")
End Function
Public Sub SetWallpaper(cFilename As Variant)
reg.ClassKey = HKEY_CURRENT_USER
reg.SectionKey = "Control Panel\Desktop"
reg.ValueKey = "Wallpaper"
reg.ValueType = REG_SZ
reg.Default = ""
reg.Value = cFilename
End Sub
Public Sub RefreshDesktop()
Dim oShell As Object
Set oShell = CreateObject("WScript.Shell")
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
End Sub
Perhaps there's some other setting that's required. Any ideas?
Solution
I'm not sure if there's an official API for this, but if you have your heart set on it you could use Sysinternal's Process Monitor and see what registry keys get touched when you set an HTML desktop background via the UI. Then you'd just need to repeat those edits in your code. However, an API call would be far preferable in terms of backward/forward compatibility.
OTHER TIPS
I think you need to make sure "Active Desktop" is turned on.
You might try setting HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn
to 1
(found here).
I haven't tried it, so no guarantees.
Okay, I've discovered the answer to my question, thanks to egl1044 on Experts Exchange. Essentially, one must talk to the IActiveDesktop object. A good implementation of that, in VB6, can be found at VB6 - JPEGs as wallpapers (without conversion).
I recomend only BMP format. Do not use ActiveDesctop, because you PC will work slowly after that.
Getting closer: http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2rkbook/gp.mspx?mfr=true
But it turns out that I was getting sidetracked in Policy space. What I really wanted was to set the desktop in the userspace and let the Policy settings stand. Some helpful stuff was found here: http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx.
This isn't the final solution, however. The control of HTML desktops is still out of reach.
Seems that HTML settings are stored in HKCU\Software\Microsoft\Internet Explorer\Desktop\General. However, just storing them here doesn't seem to be enough. I still need to find the mechanism that lets Windows know which set of registry values to use.