Re: [python-win32] Setting UserInitials in Office

2010-05-03 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 28/04/2010 14:23, Mike Driscoll wrote:


Sorry for the delay in checking this out. I was out of the office
yesterday. Your code almost worked for reading the key, but I get a
tuple back:


[goes back to check what he wrote...]

That's why my code does this (note the nearly-invisible
underscore before the equals), discarding the datatype
value which is the second item of the tuple returned:

username, _ = _winreg.QueryValueEx (k, UserName)

TJG



Ah...I must have had something in my eye at the time. Anyway, I figured 
out how to get the information from it, but not how to write it. I tried 
writing to the Registry using _winreg.SetValueEx and passed a plain 
string and then various encoded strings (like utf16, utf32, etc). It 
writes just fine, but if I open Microsoft Word and check for the new 
initials or Full Name, Word just shows junk.


- Mike

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


Re: [python-win32] Setting UserInitials in Office

2010-05-03 Thread Tim Roberts
Mike Driscoll wrote:

 Ah...I must have had something in my eye at the time. Anyway, I
 figured out how to get the information from it, but not how to write
 it. I tried writing to the Registry using _winreg.SetValueEx and
 passed a plain string and then various encoded strings (like utf16,
 utf32, etc). It writes just fine, but if I open Microsoft Word and
 check for the new initials or Full Name, Word just shows junk.

This works:
_winreg.SetValueEx( k, UserInitials, 0, _winreg.REG_BINARY,
utimr\0 )

Note the trailing 0.

-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.

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


Re: [python-win32] Setting UserInitials in Office

2010-04-28 Thread Tim Golden

On 27/04/2010 22:43, Tim Roberts wrote:

Tim Golden wrote:

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

Mike Driscoll wrote:

...
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):


Exactly.  They are really just REG_SZ, although they set the type as
REG_BINARY for their own inscrutable reasons.



Ah. Amazing how I managed to read your explanation and then internally
translate it into meaning something rather different.

Hopefully my code will have helped the OP out at any rate... I seem to be
having a bad week for offering help :)

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


Re: [python-win32] Setting UserInitials in Office

2010-04-28 Thread Mike Driscoll

On 1:59 PM, Tim Golden wrote:

On 27/04/2010 22:43, Tim Roberts wrote:

Tim Golden wrote:

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

Mike Driscoll wrote:

...
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):


Exactly.  They are really just REG_SZ, although they set the type as
REG_BINARY for their own inscrutable reasons.



Ah. Amazing how I managed to read your explanation and then internally
translate it into meaning something rather different.

Hopefully my code will have helped the OP out at any rate... I seem to be
having a bad week for offering help :)

TJG



Sorry for the delay in checking this out. I was out of the office 
yesterday. Your code almost worked for reading the key, but I get a 
tuple back:


('m\x00l\x00d\x00\x00\x00', 3)

So I had to change your last line to: print repr (res[0].decode (utf16))

I'll try setting the value later today since that's the main goal of 
this little project. I suppose I'll need to encode it in utf16 too. 
Thanks for the assist!


- Mike
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Setting UserInitials in Office

2010-04-28 Thread Tim Golden

On 28/04/2010 14:23, Mike Driscoll wrote:


Sorry for the delay in checking this out. I was out of the office
yesterday. Your code almost worked for reading the key, but I get a
tuple back:


[goes back to check what he wrote...]

That's why my code does this (note the nearly-invisible
underscore before the equals), discarding the datatype
value which is the second item of the tuple returned:

username, _ = _winreg.QueryValueEx (k, UserName)

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


Re: [python-win32] Setting UserInitials in Office

2010-04-27 Thread Tim Golden

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,
  rSoftware\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


Re: [python-win32] Setting UserInitials in Office

2010-04-27 Thread Tim Roberts
Tim Golden wrote:
 On 26/04/2010 23:56, Tim Roberts wrote:
 Mike Driscoll wrote:
 ...
 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):

Exactly.  They are really just REG_SZ, although they set the type as
REG_BINARY for their own inscrutable reasons.

-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.

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


Re: [python-win32] Setting UserInitials in Office

2010-04-26 Thread Tim Roberts
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.

-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.

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