vb6registrydesktop-wallpaper

Windows wallpaper: not just BMPs?


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.