2016-10-17 2 views
0

Dies ist ein Teil meines Code:Attribute: Modul 'ctypes.wintypes' haben kein Attribut 'create_unicode_buffer'

import os 

def _get_appdata_path(): 
    import ctypes 
    from ctypes import wintypes, windll 
    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) 
    return path_buf.value 

Aber wenn ich wintypes.create_unicode_buffer() nennen erhalte ich die Fehlermeldung:

AttributeError: module 'ctypes.wintypes' has no attribute 'create_unicode_buffer' 

I verwende Python 3.5.1. Was könnte ich tuen?

+2

http://stackoverflow.com/questions/626796/how-do-i-find-the-windows-common-application-data-folder-using-python#comment33587651_626927 – gplayer

Antwort

3

Verwenden Sie ctypes.create_unicode_buffer, was sowohl in PY2 als auch in PY3 funktioniert. Es war nur zufällig in WinTypes in PY2 aufgrund seiner Verwendung von from ctypes import *. : D

Verwandte Themen