我一直在寻找如何使用IActiveDesktop来更改墙纸,并拼凑了以下来自不同来源的代码。在
sys.coinit_flags = 0
pythoncom.CoInitialize()
iad = pythoncom.CoCreateInstance(shell.CLSID_ActiveDesktop, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IActiveDesktop)
iad.SetWallpaper(bmpPath)
iad.ApplyChanges(7)
我得到以下错误:
pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)
我真的不知道我在这里做什么。在
请注意,我不想使用SystemParametersInfo,因为它没有IActiveDesktop明显具有的淡入效果。在
我想您只是缺少了
SetWallPaper
的第二个参数,它应该总是0。 这对我有用:参考号:IActiveDesktop::ApplyChanges Method
相关问题 更多 >
编程相关推荐