Saving Files Under Windows

achrist at easystreet.com achrist at easystreet.com
Fri Jun 13 13:47:35 EDT 2003


Thanks to all for the advice.  To recap:

It looks like this is all OS-version-specific.  I guess I'd like to
just put the data into the application directory on OS's prior to
Win2k.  If you upgrade a system from Win98 or NT to WinXP is the
user screwed by having all their data in the wrong place anyhow?

Trying to figure out how to figure out which OS version I'm dealing
with, I try:

>>> import win32api
>>> win32api.GetVersionEx()
(4, 0, 1381, 2, 'Service Pack 6')

I infer that the major version is the first value in the tuple
returned, and that if I see 4 or less, I've got an old system
where I can allow or encourage the user to do what I've usually
done, ie put data into a sub-folder of the app directory.  (File
save dialogs start someplace within the application folder).

If the major version is 5 or more, I've got 2k or XP or something
newer  (maybe worse?), and I should look in the registry at 

1. For 1-user data

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders\

My choice of registry value names may be "AppData", "Local AppData", 
and "Personal". I'll probably go with "AppData", if I find it. Any
suggestions which is preferred? Anything else to look at on newer
Windows versions?

2. If I don't find anything, I try:

	C:\Documents and Settings\<username>\Application Data\

3. For data shared among several users:

HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders\

Where I find a value named "Common AppData". Anything else to look at on
newer Windows versions?

4. If I don't find anything, I try:

	C:\Documents and Settings\All Users\Application Data\

File save dialogs for Win2k or newer will start in a subfolder of
the folder found by steps 1-4. 

The python win32api should make all of this duck soup.  Any pitfalls?


Al




More information about the Python-list mailing list