On 26/04/2010 23:56, Tim Roberts wrote:
Mike Driscoll wrote:

I am looking for a way to set the UserInitials and Username in
Microsoft Office applications. The reason is that we have had some
users who have managed to put their initials into some Office programs
when a different user was logged in and this has made it difficult to
tell who has what open. From what I've read so far, the information is
encoded in the Registry here:

HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo

I tried to use the base64 module to decode it, but I must be doing
something wrong. Does anyone know of a good way to get and set this
information? I am dealing with users on Windows XP and Python 2.4

???  The strings in there are not encoded in any way.  They are
plaintext Unicode strings.  They happen to be identified as REG_BINARY,
but that's just a silly accident.


On my (WinXP SP3, Office 2003) machine, they look to be utf16-encoded
strings (null-terminated):

<code>
import _winreg

k = _winreg.OpenKey (
  _winreg.HKEY_CURRENT_USER,
  r"Software\Microsoft\Office\11.0\Common\UserInfo"
)
username, _ = _winreg.QueryValueEx (k, "UserName")
print repr (username)
# 'g\x00o\x00l\x00d\x00e\x00n\x00t\x00\x00\x00'
print repr (username.decode ("utf16"))
# u'goldent\x00'

</code>

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to