Windows 壁纸:不仅仅是 BMP?
我在几个地方读到桌面壁纸可以设置为 HTML 文档。 有没有人成功地以编程方式更改它?
下面的 VB6 片段帮助我为 BMP 设置一些东西,但是当我尝试将它用于 HTML 时,我得到了漂亮的蓝色背景,没有其他任何东西。
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
也许还需要一些其他设置。 有任何想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
更接近: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.
然而,这不是最终的解决方案。 HTML 桌面的控制仍然遥不可及。
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.
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.
我推荐只使用 BMP 格式。 不要使用ActiveDetop,因为此后你的电脑运行速度会变慢。
I recomend only BMP format. Do not use ActiveDesctop, because you PC will work slowly after that.
好的,我已经找到了问题的答案,感谢 专家交流。 本质上,我们必须与 IActiveDesktop 对象对话。 在 VB6 中,可以在 VB6 - JPEG 作为壁纸(没有转换)。
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).
我不确定是否有官方 API,但如果您愿意,您可以使用 Sysinternal 的 进程监视器 并查看当您通过 UI 设置 HTML 桌面背景时会触及哪些注册表项。 然后您只需要在代码中重复这些编辑即可。 然而,就向后/向前兼容性而言,API 调用要好得多。
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.
我认为您需要确保“活动桌面”已打开。
您可以尝试将
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn
设置为1
(发现 此处)。我没有尝试过,所以不能保证。
I think you need to make sure "Active Desktop" is turned on.
You might try setting
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ForceActiveDesktopOn
to1
(found here).I haven't tried it, so no guarantees.