#NEWLINE# def _get_win_folder_with_jna( csidl_name ) : #NEWLINE# #INDENT# import array #NEWLINE# from com.sun import jna #NEWLINE# from com.sun.jna.platform import win32 #NEWLINE# buf_size = ( win32 . WinDef . MAX_PATH * 2 ) #NEWLINE# buf = array . zeros ( 'c' , buf_size ) #NEWLINE# shell = win32 . Shell32 . INSTANCE #NEWLINE# shell . SHGetFolderPath ( None , getattr ( win32 . ShlObj , csidl_name ) , None , win32 . ShlObj . SHGFP_TYPE_CURRENT , buf ) #NEWLINE# dir = jna . Native . toString ( buf . tostring ( ) ) . rstrip ( '\x00' ) #NEWLINE# has_high_char = False #NEWLINE# for c in shell : #NEWLINE# #INDENT# if ( ord ( c ) > 255 ) : #NEWLINE# #INDENT# has_high_char = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if has_high_char : #NEWLINE# #INDENT# buf = array . zeros ( 'c' , buf_size ) #NEWLINE# kernel = win32 . Kernel32 . INSTANCE #NEWLINE# if kernal . GetShortPathName ( dir , buf , buf_size ) : #NEWLINE# #INDENT# dir = jna . Native . toString ( buf . tostring ( ) ) . rstrip ( '\x00' ) #NEWLINE# #UNINDENT# #UNINDENT# return dir