Windows Installation

Trent Mick trentm at ActiveState.com
Fri Mar 15 17:23:58 EST 2002


[Fernando Pérez wrote]
> John Roth wrote:
> 
> > 
> > Putting something into the start menu is dead easy. Just put a
> > link to the appropriate file into "c:Windows/Start Menu/Programs"
> > Note the blank, and watch your capitalization. Windows is
> > flaky about capitalization.
> > 
> 
> This is only for win9x. Win2k/xp have per-user Start Menu dirs, and their 
> location must be retrieved from the registry (Def. is C:\documents and 
> settings\user-name\Start Menu, but it can vary). So to have this be reliable, 
> there's no way around diving into the pleasures of the registry.

Not true. There is a win32api call to get these directories. Mind you, that
requires you to have the PyWin32 extensions installed.



>>> from win32com.shell import shellcon, shell
>>> shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
u'C:\\Documents and Settings\\trentm\\Application Data'
>>> shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
u'C:\\Documents and Settings\\All Users\\Application Data'
>>>
>>> shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_STARTMENU, 0, 0)
u'C:\\Documents and Settings\\All Users\\Start Menu'

If you are running on Win9x then you will get different directories
appropriate for that version of Windows.

See this link for other CSIDL_*'s
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/Shell/reference/enums/csidl.asp


Cheers,
Trent

-- 
Trent Mick
TrentM at ActiveState.com




More information about the Python-list mailing list