def get_user_config_dir():
"""Platform specific directory for user configuration.
:returns: returns the user configuration directory.
:rtype: string
"""
if os.name == 'nt':
try:
csidl_appdata = 26
shgetfolderpath = windll.shell32.SHGetFolderPathW
shgetfolderpath.argtypes = [wintypes.HWND, ctypes.c_int, \
wintypes.HANDLE, wintypes.DWORD, wintypes.LPCWSTR]
path_buf = wintypes.create_unicode_buffer(wintypes.MAX_PATH)
result = shgetfolderpath(0, csidl_appdata, 0, 0, path_buf)
if result == 0:
return path_buf.value
except ImportError:
pass
return os.environ['APPDATA']
else:
return os.path.expanduser('~')
评论列表
文章目录