[PythonCE] How to determine special folder location

Adam Walley adam.walley at gmail.com
Tue Mar 30 00:52:53 CEST 2010


Nice work.

I will definitely make a note of that one.

Thanks rodi.

Adam.

On 29 March 2010 23:02, rodi <c22rs at web.de> wrote:

> Hello PytonCE users,
>
> have solved the question. The appropriate function
> is 'SHGetSpecialFolderPath': see
> http://msdn.microsoft.com/en-us/library/aa931257.aspx
>
> May be this info and the follwing code snippet is helpfull to others :)
>
> import ctypes
> from time import sleep
>
> HANDLE = ctypes.c_ulong
> HWND = HANDLE
> INT = ctypes.c_int
> BOOL = ctypes.c_int
>
> SHGetSpecialFolderPath = ctypes.windll.coredll.SHGetSpecialFolderPath
> # BOOL SHGetSpecialFolderPath( HWND hwndOwner, LPTSTR lpszPath, int
> nFolder,
> BOOL fCreate );
> SHGetSpecialFolderPath.argtypes = [HWND, ctypes.c_wchar_p, INT, BOOL]
> MAX_PATH = 260
> path = ctypes.create_unicode_buffer(MAX_PATH)
> for i in range(0, 60): #[CSIDL_STARTMENU, CSIDL_PROGRAMS]:
>    try:
>        SHGetSpecialFolderPath( 0,  path, i, 0)
>        if len(path.value)>0:
>            print i, path.value
>        else:
>            print i, 'not supported'
>    except Exception, e:
>        print i, 'exception', e
> sleep(5)
>
>
> Cheers rodi.
> _______________________________________________
> PythonCE mailing list
> PythonCE at python.org
> http://mail.python.org/mailman/listinfo/pythonce
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonce/attachments/20100329/dce73e25/attachment.html>


More information about the PythonCE mailing list