<DIV>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>Sorry for jumping to conclusions in my earlier reply.</DIV>
<DIV> Contrary to my earlier belief a non-administrative user can change the registry values under HKEY_CURRENT_USER.</DIV>
<DIV>The problem was in code itself.</DIV>
<DIV> </DIV>
<DIV>While using the SetValueEx function the key identified by the key parameter must have been opened with <TT class=constant>KEY_SET_VALUE</TT> access. <BR></DIV>
<DIV>The default is KEY_READ access.</DIV>
<DIV> </DIV>
<DIV>Hence this should ( and in fact does) work:</DIV>
<DIV> </DIV>
<DIV>>import _winreg as wreg<BR>><BR>>key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, "Control Panel\\Desktop",<STRONG> 0, KEY_SET_VALUE )<BR></STRONG>>v = wreg.QueryValueEx(key,"WallPaper")<BR>>print "Key value is : ", v<BR>>wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])</DIV>
<DIV> </DIV>
<DIV>Shitiz<BR></DIV>
<DIV><B><I></I></B> </DIV>
<DIV><B><I>Chris Barnhart <mlist-python@dideas.com></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Shitiz,<BR><BR>Thank you for your help, I was a little rushed in my first post and left <BR>out some important details.<BR><BR>Although the application is to change the wallpaper, the lesson I want to <BR>learn is the modification of the registry.<BR><BR>Because the key-value I'm trying to change is in HKEY_CURRENT_USER <BR>shouldn't a non-privileged user be able to change it? I also happen to be <BR>running as ADMINISTRATOR which I should mentioned.<BR><BR>Chris<BR><BR>PS : Simply changing the wallpaper file won't actually change the wallpaper <BR>immediately. Possibly if I ran a "system parameters changed" function <BR>afterward, it would then update the desktop. I even have to do this after <BR>changing the registry value.<BR><BR><BR><BR>At 04:39 PM 11/2/2004, Shitiz Bansal wrote:<BR>>Hi,<BR>><BR>>you could do either of the following:<BR>><BR>>1. replace the
wallpaper file itself without touching the registry , by <BR>>using commands from os module.<BR>>2. What i gather is that as a non-adminstrative user you dont have <BR>>permission to change the registry. So u could use the LogonUser and <BR>>ImpersonateLoggedonUser functions from win32security module to impersonate <BR>>as the administrator before editing the registry.<BR>><BR>>tell me if it helps.<BR>><BR>>shitiz<BR>><BR>><BR>>Chris Barnhart <MLIST-PYTHON@DIDEAS.COM>wrote:<BR>>Hi,<BR>><BR>>I'm attempting to write a python (2.3.3) program that will update the<BR>>wallpaper under Windows 2000. I found an example delphi program :<BR>>(http://www.latiumsoftware.com/en/delphi/00020.php) which suggest that I<BR>>need to change a registry variable, and then execute a system parameters<BR>>changed statement.<BR>><BR>>The following program attempts to change the desktop wallpaper by changing<BR>>a key in the
HKEY_CURRENT_USER. This fails due to access denied? I'm<BR>>using methods from _winreg.<BR>><BR>>What weird, is that by using OpenKey I've been able to create new registry<BR>>sub folders, and then using SetValue, change the value of the "default" key.<BR>><BR>>I've also looked modifying the registry from WMI, and also looked at using<BR>>windll - but obsolete.<BR>><BR>>Any ideas?<BR>><BR>>Thank you,<BR>>Chris<BR>><BR>>--------------<BR>><BR>><BR>><BR>>import _winreg as wreg<BR>><BR>>key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, "Control Panel\\Desktop")<BR>>v = wreg.QueryValueEx(key,"WallPaper")<BR>>print "Key value is : ", v<BR>>wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])<BR>><BR>>C:\src\python>python r3.py<BR>>Key value is : (u'C:\\WINNT\\Mozilla Wallpaper.bmp', 1)<BR>>Traceback (most recent call last):<BR>>File "r3.py", line 6, in ?<BR>>wreg.SetValueEx(key, "WallPaper", 0,
wreg.REG_SZ, v[0])<BR>>WindowsError: [Errno 5] Access is denied<BR><BR>_______________________________________________<BR>Tutor maillist - Tutor@python.org<BR>http://mail.python.org/mailman/listinfo/tutor<BR></BLOCKQUOTE></DIV><p>
        
                <hr size=1>Do you Yahoo!?<br>
Check out the new Yahoo! Front Page. <a href="http://www.yahoo.com"> www.yahoo.com</a