how could I get (using Python) the path to the Desktop in a universal way (under Windows), such as "C:\Documents and Settings\All Users\Desktop"?
Thanks,
Cristina.
···
-------------------------------------------------------
Xnet scaneaza automat toate mesajele impotriva virusilor folosind RAV AntiVirus.
Xnet automatically scans all messages for viruses using RAV AntiVirus.
Nota: RAV AntiVirus poate sa nu detecteze toti virusii noi sau toate variantele lor. Va rugam sa luati in considerare ca exista un risc de fiecare data cand deschideti fisiere atasate si ca MobiFon nu este responsabila pentru nici un prejudiciu cauzat de virusi.
Disclaimer: RAV AntiVirus may not be able to detect all new viruses and variants. Please be aware that there is a risk involved whenever opening e-mail attachments to your computer and that MobiFon is not responsible for any damages caused by viruses.
This isn't exactly what you want, but should be close. Import the os module,
then check:
os.environ['USERPROFILE']
On Windows 2000: \Documents and Settings\%UserName%
On Windows NT 4.0: \Winnt\Profiles\%UserName%
On Windows 98: \Windows\Profiles\%UserName%
On Windows Me: \Windows\Profiles\%UserName%
On Windows 2000 after upgrading from Windows NT 4.0:
\Winnt\Profiles\%UserName%
XP is probably the same as Windows 2000, but corrections would be welcome.
I don't know of any environment variable that specifically references the
Desktop, but perhaps there is something in the registry.
ka
···
-----Original Message-----
From: C. Iacob [mailto:cai@xnet.ro]
Sent: Tuesday, November 26, 2002 2:35 PM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] path to Desktop
Hi,
how could I get (using Python) the path to the Desktop in a universal way
(under Windows), such as "C:\Documents and Settings\All Users\Desktop"?
Proper ("the right way as spec'd by MS") Python approach is probably to use the win32 shell module (there may be a wxPython-specific approach that eliminates the external dependency)...
# this gets the My Documents folder (taken from ConflictSolver)
from win32com.shell import shell, shellcon
return shell.SHGetFolderPath( 0, shellcon.CSIDL_PERSONAL, 0, 0 ).encode()
Note the use of encode to get a string instead of Unicode value.
If I'm not mistaken, you want to use:
shellcon.CSIDL_DESKTOPDIRECTORY
as the CSIDL for getting the directory in which desktop objects are stored (see the documentation on CSIDL for details).
HTH,
Mike
C. Iacob wrote:
Hi,
how could I get (using Python) the path to the Desktop in a universal way (under Windows), such as "C:\Documents and Settings\All Users\Desktop"?