[python-win32] Winshell issues
Michael M Mason
michael at shamirlens.co.uk
Thu Aug 13 13:11:22 CEST 2009
Mike Driscoll wrote:-
> Michael M Mason wrote:
> >> Hi,
> >>
> >> I've been using Tim Golden's winshell module for a
> >> couple of years and just in the last week or so, I've
> >> been receiving the following error from multiple users:
[snip]
> > I'm using Python 3 so I had to mess about to get winshell.py
> > to work. I've also found that the results returned from
> > winshell are byte arrays whereas the results returned from
> > the example above are strings. I don't know whether that
> > matters in Python 2.4, but it matters in Python 3.
> >
> > I have no idea at all why you should suddenly have a problem
> > if it was working before.
>
> Well, I haven't figured it out either. One of my colleagues suggested
> that maybe a MS update broke something, which is possible I suppose.
> They've been releasing a lot of updates lately. For the time being,
> I've wrapped it in a try/except and am creating the path in a more
> convoluted fashion if it fails. Not ideal, but it works. Hopefully
> Golden will have an idea.
You could try running the following code snippet to see what results
you get:-
from win32com.shell import shell
for i in range(0,60):
try:
print(i, shell.SHGetSpecialFolderPath(0, i, 0))
except:
print(i)
This will print a list of the folder paths you can retrieve and tell
you which value of 'i' gets that value. The blank lines are values
that don't work, which may be because they aren't defined or it may be
because the folder is a 'virtual' folder that has no physical location
on the disk.
Equipped with the info from the code snippet you could then use code
like this to retrieve certain know folders:-
mydocs = shell.SHGetSpecialFolderPath(0, 5, 0)
allusersdocs = shell.SHGetSpecialFolderPath(0, 46, 0)
Hope that helps
--
Michael
More information about the python-win32
mailing list