Saving Files Under Windows
Tim Golden
tim.golden at viacom-outdoor.co.uk
Mon Jun 16 06:03:23 EDT 2003
> Dennis Lee Bieber:
> Is there some easy way to define M$'s "My <bleeping this & that>"
> to use a separate partition?
Someone, somewhere recently has pointed out that TweakUI and various
other tools from Microsoft and elsewhere will do this. If you're
administering an NT domain (which you're obviously not on your
own laptop, unless you have delusions of grandeur) then the NT
Policies will allow you to do this as well.
[http://groups.google.com/groups?q=tweakui+group:comp.lang.python.*&hl=en&lr
=&ie=UTF-8&group=comp.lang.python.*&selm=OzSGa.44430%24rO.4390296%40newsread
1.prod.itd.earthlink.net&rnum=1]
In fact, there is a lot to be known about MS Windows in its various
incarnations that isn't known by the casual user, and not even by
the administrators in some cases. As a rule, direct access to the
registry is not the best way to read/write system info (unless of
course there is no other), not least because it changes so damned
often: what looked like a stable lookup in Win98 suddenly isn't there
when you get to Win2k.
Functions like SHGetSpecialFolderPath, available via the shell module
in win32all will get pretty much anything you like of the [My Documents]
variety, regardless of the environment, changes of location, use of
domain etc. At least, I've used them across a mixed Win2k / Win9x
setup with no problems at all.
Examples:
from win32com import storagecon
from win32com.shell import shell, shellcon
def desktop (common=0):
return shell.SHGetSpecialFolderPath (0, (shellcon.CSIDL_DESKTOP,
shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[common])
def application_data (common=0):
return shell.SHGetSpecialFolderPath (0, (shellcon.CSIDL_APPDATA,
shellcon.CSIDL_COMMON_APPDATA)[common])
def personal_folder ():
return shell.SHGetSpecialFolderPath (0, shellcon.CSIDL_PERSONAL)
my_documents = personal_folder
etc. etc.
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list