<DIV>
<DIV>Hi,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Sorry for jumping to conclusions in my earlier reply.</DIV>
<DIV>&nbsp;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>&nbsp;</DIV>
<DIV>While using the SetValueEx function the&nbsp; 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>&nbsp;</DIV>
<DIV>Hence this should ( and in fact does)&nbsp;work:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt;import _winreg as wreg<BR>&gt;<BR>&gt;key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, "Control Panel\\Desktop",<STRONG> 0, KEY_SET_VALUE )<BR></STRONG>&gt;v = wreg.QueryValueEx(key,"WallPaper")<BR>&gt;print "Key value is : ", v<BR>&gt;wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])</DIV>
<DIV>&nbsp;</DIV>
<DIV>Shitiz<BR></DIV>
<DIV><B><I></I></B>&nbsp;</DIV>
<DIV><B><I>Chris Barnhart &lt;mlist-python@dideas.com&gt;</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>&gt;Hi,<BR>&gt;<BR>&gt;you could do either of the following:<BR>&gt;<BR>&gt;1. replace the
 wallpaper file itself without touching the registry , by <BR>&gt;using commands from os module.<BR>&gt;2. What i gather is that as a non-adminstrative user you dont have <BR>&gt;permission to change the registry. So u could use the LogonUser and <BR>&gt;ImpersonateLoggedonUser functions from win32security module to impersonate <BR>&gt;as the administrator before editing the registry.<BR>&gt;<BR>&gt;tell me if it helps.<BR>&gt;<BR>&gt;shitiz<BR>&gt;<BR>&gt;<BR>&gt;Chris Barnhart <MLIST-PYTHON@DIDEAS.COM>wrote:<BR>&gt;Hi,<BR>&gt;<BR>&gt;I'm attempting to write a python (2.3.3) program that will update the<BR>&gt;wallpaper under Windows 2000. I found an example delphi program :<BR>&gt;(http://www.latiumsoftware.com/en/delphi/00020.php) which suggest that I<BR>&gt;need to change a registry variable, and then execute a system parameters<BR>&gt;changed statement.<BR>&gt;<BR>&gt;The following program attempts to change the desktop wallpaper by changing<BR>&gt;a key in the
 HKEY_CURRENT_USER. This fails due to access denied? I'm<BR>&gt;using methods from _winreg.<BR>&gt;<BR>&gt;What weird, is that by using OpenKey I've been able to create new registry<BR>&gt;sub folders, and then using SetValue, change the value of the "default" key.<BR>&gt;<BR>&gt;I've also looked modifying the registry from WMI, and also looked at using<BR>&gt;windll - but obsolete.<BR>&gt;<BR>&gt;Any ideas?<BR>&gt;<BR>&gt;Thank you,<BR>&gt;Chris<BR>&gt;<BR>&gt;--------------<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt;import _winreg as wreg<BR>&gt;<BR>&gt;key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, "Control Panel\\Desktop")<BR>&gt;v = wreg.QueryValueEx(key,"WallPaper")<BR>&gt;print "Key value is : ", v<BR>&gt;wreg.SetValueEx(key, "WallPaper", 0, wreg.REG_SZ, v[0])<BR>&gt;<BR>&gt;C:\src\python&gt;python r3.py<BR>&gt;Key value is : (u'C:\\WINNT\\Mozilla Wallpaper.bmp', 1)<BR>&gt;Traceback (most recent call last):<BR>&gt;File "r3.py", line 6, in ?<BR>&gt;wreg.SetValueEx(key, "WallPaper", 0,
 wreg.REG_SZ, v[0])<BR>&gt;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