How to get the user name, and to show a select directory dialog?

Peter Hansen peter at engcorp.com
Fri May 23 09:23:01 EDT 2003


Tim Golden wrote:
> 
> The first has already been answered (win32api.GetUserName), altho' I
> would point out that this won't work on Win9x (try
> win32wnet.WNetGetuser instead). 

Not so sure about that.  I'm on Windows 98 SE:

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32api
>>> win32api.GetUserName()
'phansen'

So, looks like that *does* work.

>>> import win32wnet
>>> win32wnet.WNetGetuser()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'WNetGetuser'
>>> win32wnet.WNetGetUser()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: Couldn't get the buffer size!

Looks like, possibly WNetGetUser() (note capitalization) exists but
has a problem internally, but WNetGetuser() does not even exist.

-Peter




More information about the Python-list mailing list