[Tutor] Problem modify windows registry (desktop wallpaper)

Shitiz Bansal shitizb at yahoo.com
Tue Nov 2 22:39:43 CET 2004


Hi,
 
you could do either of the following:
 
1. replace the wallpaper file itself without touching the registry , by using commands from os module.
2. What i gather is that as a non-adminstrative user you dont have permission to change the registry. So u could use the LogonUser and ImpersonateLoggedonUser functions from win32security module to impersonate as the administrator before editing the registry.
 
tell me if it helps.
 
shitiz


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?

Thank you,
Chris

--------------


import _winreg as wreg

key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, "Control Panel\\Desktop")
v = wreg.QueryValueEx(key,"WallPaper")
print "Key value is : ", v
wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])

C:\src\python>python r3.py
Key value is : (u'C:\\WINNT\\Mozilla Wallpaper.bmp', 1)
Traceback (most recent call last):
File "r3.py", line 6, in ?
wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])
WindowsError: [Errno 5] Access is denied

_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor

			
---------------------------------
Do you Yahoo!?
 Check out the new Yahoo! Front Page.  www.yahoo.com/a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20041102/b50a0652/attachment.htm


More information about the Tutor mailing list