Remove test for presence of ctypes (assumed present in global imports).
This commit is contained in:
parent
721f74d8c2
commit
9858ccf207
|
@ -29,20 +29,14 @@ import array
|
||||||
import platform
|
import platform
|
||||||
import ctypes.wintypes
|
import ctypes.wintypes
|
||||||
|
|
||||||
# if you're on windows, you should have one of these, i guess?
|
# if pywin32 is available, use it
|
||||||
# ctypes is part of standard library since Python 2.5
|
|
||||||
_has_win32all = False
|
_has_win32all = False
|
||||||
_has_ctypes = False
|
|
||||||
try:
|
try:
|
||||||
# win32gui is preferred over win32ui to avoid MFC dependencies
|
# win32gui is preferred over win32ui to avoid MFC dependencies
|
||||||
import win32gui
|
import win32gui
|
||||||
_has_win32all = True
|
_has_win32all = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
pass
|
||||||
import ctypes
|
|
||||||
_has_ctypes = True
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
_AGENT_COPYDATA_ID = 0x804e50ba
|
_AGENT_COPYDATA_ID = 0x804e50ba
|
||||||
_AGENT_MAX_MSGLEN = 8192
|
_AGENT_MAX_MSGLEN = 8192
|
||||||
|
@ -58,7 +52,7 @@ def _get_pageant_window_object():
|
||||||
return hwnd
|
return hwnd
|
||||||
except win32gui.error:
|
except win32gui.error:
|
||||||
pass
|
pass
|
||||||
elif _has_ctypes:
|
else:
|
||||||
# Return 0 if there is no Pageant window.
|
# Return 0 if there is no Pageant window.
|
||||||
return ctypes.windll.user32.FindWindowA('Pageant', 'Pageant')
|
return ctypes.windll.user32.FindWindowA('Pageant', 'Pageant')
|
||||||
return None
|
return None
|
||||||
|
@ -71,9 +65,7 @@ def can_talk_to_agent():
|
||||||
This checks both if we have the required libraries (win32all or ctypes)
|
This checks both if we have the required libraries (win32all or ctypes)
|
||||||
and if there is a Pageant currently running.
|
and if there is a Pageant currently running.
|
||||||
"""
|
"""
|
||||||
if (_has_win32all or _has_ctypes) and _get_pageant_window_object():
|
return bool(_get_pageant_window_object())
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
ULONG_PTR = ctypes.c_uint64 if platform.architecture()[0] == '64bit' else ctypes.c_uint32
|
ULONG_PTR = ctypes.c_uint64 if platform.architecture()[0] == '64bit' else ctypes.c_uint32
|
||||||
class COPYDATASTRUCT(ctypes.Structure):
|
class COPYDATASTRUCT(ctypes.Structure):
|
||||||
|
@ -114,10 +106,8 @@ def _query_pageant(msg):
|
||||||
# win32gui.SendMessage should also allow the same pattern as
|
# win32gui.SendMessage should also allow the same pattern as
|
||||||
# ctypes, but let's keep it like this for now...
|
# ctypes, but let's keep it like this for now...
|
||||||
response = win32gui.SendMessage(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.addressof(cds))
|
response = win32gui.SendMessage(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.addressof(cds))
|
||||||
elif _has_ctypes:
|
|
||||||
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.byref(cds))
|
|
||||||
else:
|
else:
|
||||||
response = 0
|
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.byref(cds))
|
||||||
|
|
||||||
if response > 0:
|
if response > 0:
|
||||||
datalen = pymap.read(4)
|
datalen = pymap.read(4)
|
||||||
|
|
Loading…
Reference in New Issue