本文整理匯總了Python中ctypes.windll.LoadLibrary方法的典型用法代碼示例。如果您正苦於以下問題:Python windll.LoadLibrary方法的具體用法?Python windll.LoadLibrary怎麽用?Python windll.LoadLibrary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ctypes.windll
的用法示例。
在下文中一共展示了windll.LoadLibrary方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __start__
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def __start__(self):
self.dll = None
try:
self.dll = windll.LoadLibrary("TellUsbD101.dll")
except:
raise eg.Exception("TellUsbD101.dll not found.")
示例2: test_handler
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def test_handler(self):
@count_calls
def interrupt_polling():
print('Caught CTRL-C!')
from ctypes import windll
from ctypes.wintypes import BOOL, DWORD
kernel32 = windll.LoadLibrary('kernel32')
# <http://msdn.microsoft.com/en-us/library/ms683155.aspx>
GenerateConsoleCtrlEvent = kernel32.GenerateConsoleCtrlEvent
GenerateConsoleCtrlEvent.argtypes = (DWORD, DWORD)
GenerateConsoleCtrlEvent.restype = BOOL
# Simulate CTRL-C event while handler is active.
try:
with allow_interrupt(interrupt_polling) as context:
result = GenerateConsoleCtrlEvent(0, 0)
# Sleep so that we give time to the handler to
# capture the Ctrl-C event.
time.sleep(0.5)
except KeyboardInterrupt:
pass
else:
if result == 0:
raise WindowsError()
else:
self.fail('Expecting `KeyboardInterrupt` exception!')
# Make sure our handler was called.
self.assertEqual(interrupt_polling.__calls__, 1)
示例3: _link_library
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def _link_library(self, lib_path, convention):
"""Find and link the external librairy if only a path was provided.
"""
if convention == 'cdll':
return cdll.LoadLibrary(lib_path)
elif convention == 'windll':
return windll.LoadLibrary(lib_path)
elif convention == 'oledll':
return oledll.LoadLibrary(lib_path)
else:
raise ValueError('Convention cannot be {}'.format(convention))
示例4: get_lsass_handle
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def get_lsass_handle():
your_dll = windll.LoadLibrary(dll_path)
_your_function = your_dll.your_function
_your_function.argtypes = [] #I guess no args
_your_function.restype = c_void_p #this is basically a handle
phandle = _your_function()
return phandle
示例5: get_winfunc
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def get_winfunc(libname, funcname, restype=None, argtypes=(), _libcache={}):
"""Retrieve a function from a library/DLL, and set the data types."""
if libname not in _libcache:
_libcache[libname] = windll.LoadLibrary(libname)
func = getattr(_libcache[libname], funcname)
func.argtypes = argtypes
func.restype = restype
return func
示例6: get_winfunc
# 需要導入模塊: from ctypes import windll [as 別名]
# 或者: from ctypes.windll import LoadLibrary [as 別名]
def get_winfunc(libname, funcname, restype=None, argtypes=(), _libcache={}):
"""Retrieve a function from a library, and set the data types."""
from ctypes import windll
if libname not in _libcache:
_libcache[libname] = windll.LoadLibrary(libname)
func = getattr(_libcache[libname], funcname)
func.argtypes = argtypes
func.restype = restype
return func