2016-06-03 2 views
0

정말 어리석은 질문입니다. 미안합니다. 파이썬에서의 첫날입니다.ctypes.windll.shell32.IsUserAnAdmin을 임포트하면 ImportError가 발생합니다.

나는 그렇게처럼 'IsUserAnAdmin'기능을 가져올 :

from ctypes.windll.shell32 import IsUserAnAdmin 

내가 분명히 뭔가를 잘못하고 있어요 내가 갖는 이유는 내가 가져올 때

ImportError: No module named 'ctypes.windll'

모든 것이 잘 작동 전체 'ctypes',하지만 난 정말 그걸로 기능을 호출하고 싶지 않아요 :

...보다 :

ctypes.windll.shell32.IsUserAnAdmin() 

누군가이 기능을 가져 오는 방법을 알려줄 수 있습니까? 사전에

감사합니다 :)

답변

2

windllLibraryLoader 개체가 아니라 module입니다. 당신이 docs를 읽는다면, 당신은 가져 오기가 완료되었습니다 알 같은 :

This class represents a dll exporting functions using the Windows stdcall calling convention.

그래서 당신은 할 수 있습니다 :

>>> IsUserAnAdmin = WinDLL('Shell32').IsUserAnAdmin 
>>> IsUserAnAdmin() 
0 
WinDLL이 문서 읽기 클래스가

>>> from ctypes import * 
>>> print windll.Shell32.IsUserAnAdmin() 
0 

windll = LibraryLoader(WinDLL)