Windows XP - Environment variable - Unicode

Georges JEGO gjego at free.fr
Sat Jul 12 10:54:46 EDT 2003


sebastien.hugues wrote:
> Hi
> 
> I would like to retrieve the application data directory path of the 
> logged user on
> windows XP. To achieve this goal i use the environment variable
> APPDATA.
> 

As an alternative,  you can query the registry:

from _winreg import *
key=HKEY_CURRENT_USER
subKey=r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
key=OpenKey(key, subKey )
dataDir=QueryValueEx(key, "AppData")
print `dataDir[0]`

gives:
u'C:\\Documents and Settings\\jego\\Application Data'

HTH,
-- Georges





More information about the Python-list mailing list