[Tutor] Problem modify windows registry (desktop wallpaper)
Simon Brunning
simon.brunning at gmail.com
Tue Nov 2 10:21:35 CET 2004
On Mon, 01 Nov 2004 18:05:09 -0500, Chris Barnhart
<mlist-python at dideas.com> wrote:
> Hi,
>
> I'm attempting to write a python (2.3.3) program that will update the
> wallpaper under Windows 2000. I found an example delphi program :
> (http://www.latiumsoftware.com/en/delphi/00020.php) which suggest that I
> need to change a registry variable, and then execute a system parameters
> changed statement.
>
> The following program attempts to change the desktop wallpaper by changing
> a key in the HKEY_CURRENT_USER. This fails due to access denied? I'm
> using methods from _winreg.
>
> What weird, is that by using OpenKey I've been able to create new registry
> sub folders, and then using SetValue, change the value of the "default" key.
>
> I've also looked modifying the registry from WMI, and also looked at using
> windll - but obsolete.
>
> Any ideas?
I use ctypes[1] for this:
def setWallpaper(wallpaperPath):
wallpaperPath = ctypes.c_buffer(wallpaperPath)
ctypes.windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER,
0, wallpaperPath, 0)
--
Cheers,
Simon B,
simon.brunning at gmail.com,
http://www.brunningonline.net/simon/blog/
[1] http://starship.python.net/crew/theller/ctypes/
More information about the Tutor
mailing list