我们从Python开源项目中,提取了以下31个代码示例,用于说明如何使用ctypes.cdll.msvcrt()。
def find_msvcrt(): """Return the name of the VC runtime dll""" version = _get_build_version() if version is None: # better be safe than sorry return None if version <= 6: clibname = 'msvcrt' else: clibname = 'msvcr%d' % (version * 10) # If python was built with in debug mode import imp if imp.get_suffixes()[0][0] == '_d.pyd': clibname += 'd' return clibname+'.dll'
def find_msvcrt(): """Return the name of the VC runtime dll""" version = _get_build_version() if version is None: # better be safe than sorry return None if version <= 6: clibname = 'msvcrt' else: clibname = 'msvcr%d' % (version * 10) # If python was built with in debug mode import importlib.machinery if '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES: clibname += 'd' return clibname+'.dll'
def find_msvcrt(): """Return the name of the VC runtime dll""" version = _get_build_version() if version is None: # better be safe than sorry return None if version <= 6: clibname = 'msvcrt' elif version <= 13: clibname = 'msvcr%d' % (version * 10) else: # CRT is no longer directly loadable. See issue23606 for the # discussion about alternative approaches. return None # If python was built with in debug mode import importlib.machinery if '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES: clibname += 'd' return clibname+'.dll'
def test(): from ctypes import cdll if os.name == "nt": print cdll.msvcrt print cdll.load("msvcrt") print find_library("msvcrt") if os.name == "posix": # find and load_version print find_library("m") print find_library("c") print find_library("bz2") # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print cdll.LoadLibrary("libm.dylib") print cdll.LoadLibrary("libcrypto.dylib") print cdll.LoadLibrary("libSystem.dylib") print cdll.LoadLibrary("System.framework/System") else: print cdll.LoadLibrary("libm.so") print cdll.LoadLibrary("libcrypt.so") print find_library("crypt")
def test(): from ctypes import cdll if os.name == "nt": print(cdll.msvcrt) print(cdll.load("msvcrt")) print(find_library("msvcrt")) if os.name == "posix": # find and load_version print(find_library("m")) print(find_library("c")) print(find_library("bz2")) # getattr ## print cdll.m ## print cdll.bz2 # load if sys.platform == "darwin": print(cdll.LoadLibrary("libm.dylib")) print(cdll.LoadLibrary("libcrypto.dylib")) print(cdll.LoadLibrary("libSystem.dylib")) print(cdll.LoadLibrary("System.framework/System")) else: print(cdll.LoadLibrary("libm.so")) print(cdll.LoadLibrary("libcrypt.so")) print(find_library("crypt"))
def test(): from ctypes import cdll if os.name == "nt": sys.stdout.write('%s\n' % (cdll.msvcrt,)) sys.stdout.write('%s\n' % (cdll.load("msvcrt"),)) sys.stdout.write('%s\n' % (find_library("msvcrt"),)) if os.name == "posix": # find and load_version sys.stdout.write('%s\n' % (find_library("m"),)) sys.stdout.write('%s\n' % (find_library("c"),)) sys.stdout.write('%s\n' % (find_library("bz2"),)) # getattr ## print_ cdll.m ## print_ cdll.bz2 # load if sys.platform == "darwin": sys.stdout.write('%s\n' % (cdll.LoadLibrary("libm.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libcrypto.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libSystem.dylib"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("System.framework/System"),)) else: sys.stdout.write('%s\n' % (cdll.LoadLibrary("libm.so"),)) sys.stdout.write('%s\n' % (cdll.LoadLibrary("libcrypt.so"),)) sys.stdout.write('%s\n' % (find_library("crypt"),))