views:

422

answers:

6

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?

+2  A: 

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.

Blorgbeard
A: 

This is getting annoying. If I make the change programmatically, it doesn't work. If I make the change through the desktop properties dialog it does work, so something else apart from simply setting the wallpaper entry in the registry is required. The ForceActiveDesktopOn setting doesn't appear to have much say in what's going on.

The HTML code, by the way, is as follows:

<html>
<head>
<meta http-equiv="Content-Language" content="en-au">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>New Page 1</title>
</head>
<body>
<p>
<img border="0" dynsrc="movie_undergraduate.mpg" start="fileopen"></p>
</body>
</html>

The mpg, if you want to use that one, is found at http://www-sop.inria.fr/coprin/logiciels/ALIAS/Movie/movie_undergraduate.mpg and talks about interval calculations (an Ada implementation of which I wrote a Windows DLL wrapper for.)

Time to pull out the big guns, e.g. RegMon. Shall keep you posted.

boost
A: 

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.

boost
A: 

I recomend only BMP format. Do not use ActiveDesctop, because you PC will work slowly after that.

+1  A: 

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.

Matt
Yes, I tried that. I'm still going through voluminous amounts of data trying to figure out what does what.
boost
+1  A: 

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).

boost